To mark comments with very long URLs as SPAM in WordPress you must have access to the theme functions.php file and permission to edit it.
Spammers frequently use links to web pages that have very long URLs. Therefore, if someone publishes a comment on your WordPress site and enters a very long URL in the comment field, there is a high possibility that the comment was published by a spammer.
The snippet below allows you to mark a comment as SPAM if it contains a website URL with over 100 characters. You can increase or decrease this limit to suit your personal needs.
1 2 3 4 5 6 7 8 9 |
<?php function rkv_url_spamcheck( $approved , $commentdata ) { return ( strlen( $commentdata['comment_author_url'] ) > 100 ) ? 'spam' : $approved; } add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 ); ?> |
One thought on “Mark comments with very long URLs as SPAM in WordPress”