One of the best way to defend your site from spammers is to limit number of characters of Commenter's Name, Commenter URL and Comment contents. This trick can be useful since one of the most obvious sign of spam is the use of long characters in their spam comments. Now, you can apply this trick to your wordpress site and keep it free from spam.
Other benefit is, this character limit doesn't require plugin and this is absolutely important to keep your blog performance runs smooth, stable and always at the peak performance. Here, we're going to hack your wordpress engine by adding a little php codes. It needs only one step to apply this, just add the code below to wp-comment-post.php file.
Open your wp-comments-post.php file in your blog root directory. Find this code:
The code above may not be the same exactly, just find codes similar to it. Then copy the code below and put right after it.
Try to cut your plugin use when you can hack your wordpress engine easily, read also Automatic Post Teaser without Plugin, here you can recognize wordpress default code to help you hack your wordpress easily. Or learn to adapt plugin to theme function in Minify HTML, Javascript and CSS without Plugin.
Other benefit is, this character limit doesn't require plugin and this is absolutely important to keep your blog performance runs smooth, stable and always at the peak performance. Here, we're going to hack your wordpress engine by adding a little php codes. It needs only one step to apply this, just add the code below to wp-comment-post.php file.
Open your wp-comments-post.php file in your blog root directory. Find this code:
if ( '' == $comment_content )
wp_die( __('Error: please type a comment.') );
The code above may not be the same exactly, just find codes similar to it. Then copy the code below and put right after it.
//Begin Characters LimitIf you have read my previous post Manual Anti Spam - Math Challenge, You will see that this trick is basically the same, by hacking wp-comment-post.php engine, but off course with different function. You can then combine these two tricks (Characters limit and Manual Anti Spam) together to make your blog comment much safer from spam. Your blog now can filter commenters by serving math challenge that only human solvable as well as limiting their comment length.
if (strlen($comment_author) >25 )
wp_die( __('Sorry Your name is too long, 25 characters maximum, please go back and try again') );
if (strlen($comment_author_url) >40 )
wp_die( __('Sorry Your Website is too long, 40 characters maximum, please go back and try again') );
if (strlen($comment_content) <20 )
wp_die( __('Sorry Your comment is too short, 20 characters minimum, please go back and try again') );
if (strlen($comment_content) >500 )
wp_die( __('Sorry Your comment is too long, 500 characters maximum, please go back and try again') );
//End Characters Limit
Try to cut your plugin use when you can hack your wordpress engine easily, read also Automatic Post Teaser without Plugin, here you can recognize wordpress default code to help you hack your wordpress easily. Or learn to adapt plugin to theme function in Minify HTML, Javascript and CSS without Plugin.