Answer the question
In order to leave comments, you need to log in
Why did spam protection stop working without WordPress plugins?
Hello, in connection with the update of Wordpress, a new class WP_Comment was added, the code stopped working
add_filter('pre_comment_on_post', 'verify_spam');
function verify_spam($commentdata) {
$spam_test_field = trim($_POST['comment']);
if(!empty($spam_test_field)) wp_die('Спаму нет!');
$comment_content = trim($_POST['real-comment']);
$_POST['comment'] = $comment_content;
return $commentdata;
}
Answer the question
In order to leave comments, you need to log in
Spammers have adapted to the mold. Their field names are quite clear: comment and real-comment. A spamming bot reconfigures itself in a second.
Better use this simple plugin: https://wordpress.org/plugins/anti-spam/ . It is extremely undemanding to resources, but is 200% effective.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question