Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /******* in functions.php of active theme ********/
- /**
- * Proposition of Use of tellyworth suggestion to avoid bot spamming without modifying core
- * http://core.trac.wordpress.org/attachment/ticket/10975/wp-comment-nonce-refresh.patch
- */
- add_action('pre_comment_on_post', 'amauri_check_hidden_field');
- function amauri_check_hidden_field() {
- $user = wp_get_current_user();
- if ( !isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], "comment_form_{$comment_post_ID}") ) {
- do_action('comment_nonce_failed', $comment_post_ID);
- wp_die( __('Sorry, automated comments are not accepted.') );
- }
- }
- add_action('comment_form', 'amauri_add_hidden_field');
- function amauri_add_hidden_field() {
- wp_nonce_field("comment_form_{$post_id}", '_wpnonce', false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement