Sunday, July 7, 2013

How to detect spam comments with Very Long URL’s in Wordpress

All comments that contain super long url's in Atuthor links are spammy . I will show you on this post how to mark comments with URL's longer than 50 characters as spam.

Here all steps:

1. Click on left side at Appearance Menu -> Editor.
2. Click on the right side on functions.php file.
3. Add this php code :
  function rkv_url_spamcheck( $approved , $commentdata ) {
return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
}

add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 );



Disqus Comments