I was thinking about alternative ways to block comment spam the other day and it occurred to me that there’s potentially a simpler solution than captcha's. Keep in mind that this trick isn't foolproof but it is enough to make major number of bots confused. So here is a step by step tutorial for implementing this invisible captcha.
1. Create a input field which will be hidden by css to your comment form like below:
<input id="spamlover" name="spamlover" value="" />
before this line you can find in your theme item.php file.
<label for="title"><?php _e('Title', 'modern') ; ?>:</label><?php CommentForm::title_input_text(); ?><br />
2. Now add this css style in your theme style.css you can find in your theme folder:
/*we love spam */
#spamlover {display:none }
3. now open itemActions.php you can find in oc-includes/osclass folder and put this code
$spam = $_POST['spamlover'];
if ($spam === "") {} else {
Session::newInstance()->_setForm('commentAuthorName', $authorName);
Session::newInstance()->_setForm('commentTitle', $title);
Session::newInstance()->_setForm('commentAuthorEmail', $authorEmail);
Session::newInstance()->_setForm('commentBody', $body);
return -1;
}
before these lines
if( !preg_match('|^.*?@.{2,}\..{2,3}$|', $authorEmail)) {
Session::newInstance()->_setForm('commentAuthorName', $authorName);
Session::newInstance()->_setForm('commentTitle', $title);
Session::newInstance()->_setForm('commentBody', $body);
return 3;
}
Save every file and TADA !!! now bot will not be able to post comments on your website easily.
I have seen huge reduction in comments spam by implementing it. I was getting over 500 spam comments daily but now those are reduced to 2-3 spam daily(You can't stop human spammers anyway and i still moderate comments manually.
). For added security change "spamlover" to something else.
And as i already said that, there's nothing stopping a bot from rendering the page and determining which fields are actually visible to the user before filling any in - but that kind of bot would be considerably more complex than one that just looked at the form html. A invisible captcha is likely to be very effective at stopping simple bots.
If you have any better and simple idea or I have missed something please do share.