I haven’t done this personally, but it would be pretty easy. If you are building your comment form manually, just before the end of the </form>
put:
<?php wp_nonce_field( 'comment_nonce' ) ?>
Then, just hook into the pre_comment_on_post
action which fires when you submit a comment:
add_action( 'pre_comment_on_post', 'my_verify_comment_nonce' );
function my_verify_comment_nonce() {
check_admin_referer( 'comment_nonce' );
}
If you want to just hook into the standard comment form that Twenty Ten uses (comment_form()
) then you could instead hook into comment_form
like so:
add_action( 'comment_form', 'my_add_comment_nonce_to_form' );
function my_add_comment_nonce_to_form() {
wp_nonce_field( 'comment_nonce' );
}
Not tested, so let me know if you have any issues!
Related Posts:
- What are the package and subpackage comment for?
- adding a text message beside the comment submit button
- Akismet plugin is deleting spam despite preferences
- posts comments goes to trash
- Moving FB comments at the end of page
- Display WordPress comments before the plugins?
- how to get path to images in the uploads folder to be used in a plugin
- How to maintain W3C standards compliance of a theme
- How to export comments in WordPress?
- Difference between a theme and a plugin?
- How can I have two different urls for the same page that load two different templates?
- How to enable edit button in the theme’s customize UI?
- Facebook comments box on front page
- Ship plugin with a custom theme
- How to solve a conflict between a plugin and a theme?
- WP Config for FTP credentials
- WordPress error – PHP Fatal error: Uncaught Error: Call to undefined function register_block_type_from_metadata()
- Which hook callback has priority if both plugin and theme use the same hook?
- Force wordpress to request for FTP Info on theme/plugin install/update
- Workflow and best practice for documentation [closed]
- How to expire all wordpress user passwords instantly?
- Can I share predefined fonts from theme_support with a gutenberg component?
- How can I measure the performance of any WordPress Plugin or Theme?
- Get total number of comment of the posts written by an author
- add_action in functions.php, do_action in plugin?
- Implement plugins as part of a theme
- Theme or Plugin: Where should I write my code?
- Auto delete WordPress users according to time
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- How can I get WordPress to save comments in markdown format?
- Do I still need a theme to use page builders?
- Uncode theme content block header ignoring saved changes/not updating?
- Theme and plugin install or update display error in localhost
- Can I make a super plugin that also has a theme?
- Prevent WordPress installing plugins and themes via Admin
- Plugin Handle URL With Custom Theme
- Check for security updates
- Plugin-generated pages use Not Found or Pages Archive templates?
- Create custom registration form for WordPress Multisite
- Advanced Custom Field DatePicker [closed]
- All sites themes functions.php have been changed
- What will happen if i deactivate my visual composer plug in? [closed]
- Finding the URL to be used to check if plugin is installed with a theme
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- “No Add Button” for me to customize my WordPress with themes and pluggins
- How can I list all installed plugins/themes/versions from CLI/API?
- Is there a way to get plugins and themes not built for multisite to work on a network subsite?
- Why does my file_exist check fail?
- How to protect WordPress from security scanner [closed]
- Add back to post link on blank comment post error page
- how can I query all wordpress users of a blog
- Making that Admin Bar transparent or a blue color
- how to activate a plugin inside a theme
- Help with comments.php
- Some WordPress Posts are automatically becoming comments on other Posts
- There has been a critical error on your website – won’t fix no matter what
- Is it possible not to load theme on a specific page in wordpress?
- I receive taxonomy id
- How to extract a .wp-env.json or composer.json containing plugin versions from a production website?
- How to include files relative to a file’s directory
- How to save comment name email url fields?
- I want to use wordpress themes and plugin to develop website
- Blocking Plugin Css to load custom in template directory
- After a manual update, themes and plugins that were installed (and still in the directory) are not being seen
- Per theme plugins?
- Mobilepress fails to translate short codes
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- In Multisite Setups, how to update mass sections of sub-sites
- How to override any plugin file in the child theme
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Mobile Menu and Mobile Sidebar missing
- custom fields not displaying on wordpress site
- elementor development – custom widget like an inner section widget
- WordPress fresh installation did not update default plugin and themes to latest version
- How to store a custom theme and update it on other installations
- How to get a post views count using ‘WordPress popular posts’ plugin
- Can’t add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS
- How to prevent redoing get_posts queries and make results available to other scripts?
- Is it possible to disable a theme programmatically?
- Google trying to index child theme files
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- In the WordPress API is there a way to set the width of the post/page container
- AddThis Plugin adding html comments in P tags
- Disqus comments count taking long to update
- wp_login_form() ignoring login_form action hook
- What Are the Advantages of Using an mu-plugin
- Things that saved lose when logout
- Images is not showing after migration
- Child Theme Changes Are Not Reflecting In Parent Theme
- Automatic updates of plugins and themes outside of wordpress.org
- Input gets deleted/overwritten after changing to different Admin Menu
- How to fix vanilla comments extra iframe space
- Reply form used in wordpress.com
- Theme causing SSL break on chrome
- Why does theme need woocommerce to show images / content on front page?
- Divi Template A Few Questions
- Trying to use wp_register_script/style and enqueu them from an array – getting an error [duplicate]
- My Blog page ( posts page ) theme isn’t changing with the new theme [closed]
- How to Allow Users to Select Recipients In a WordPress Comment section?
- Very slow page loads