Arrrrgh. I’m so tired of comment spam. It’s not simply that it’s spam, it’s that it’s vulgar and repulsive. I really wish I could sue the butts off of these guys! I’m trying something a little bit different that I noticed in an entry from Seth Godin a long time ago. Since WordPress has a standard comments package, any spammer can simply post to their hearts content to the comments post file (wp-comments-post.php).
I’ve edited the comments post file to add a problem that requires a correct answer. So, when you try to comment, it’s going to simply ask you to add two numbers together. If you get the answer right, it will work. If you don’t, you’ll get an error.
Here’s how I’ve done it. In your comments post file (wp-comments-post.php), I’ve added a variable at line 25 to be collected from the post:
$comment_addition = trim($_POST['addition']);
And then at line 50 58, I make sure that the response that you post is correct… in this case = 10. Note, this must be entered in the If statement if there is NO userid (after if ( !$user->ID ) :)
if ( ’10′ != $comment_addition )
die( __(‘Error: please try your addition again.’) );
Now I have to add the fields to my theme on my comments page. This takes a little more work because you need to know where the form is on the page. It will look something like this:
>?php if ( !$user_ID ) { ?>
>p>>input class=”text_input” type=”text” name=”author” id=”author” value=”>?php echo $comment_author; ?>” tabindex=”1″ />>label for=”author”>>strong>Name>/strong>>/label>>/p>
>p>>input class=”text_input” type=”text” name=”email” id=”email” value=”>?php echo $comment_author_email; ?>” tabindex=”2″ />>label for=”email”>>strong>Mail>/strong>>/label>>/p>
>p>>input class=”text_input” type=”text” name=”url” id=”url” value=”>?php echo $comment_author_url; ?>” tabindex=”3″ />>label for=”url”>>strong>Website>/strong>>/label>>/p>
>p>>input class=”text_code” type=”text” name=”addition” id=”addition” value=”" tabindex=”4″ />>label for=”addition”>>strong>What does 8 + 2 equal?>/strong>>/label>>/p>
>?php } ?>
Notice the additional form variable that I added, called addition. Now, if someone can’t add… they can’t get their comment added. It’s simple, but effective. On I Choose Indy! I’ve modified it a little, and asked for the area code of Indianapolis. (Hey Pat, I updated yours and tested it as well!).
Here’s why I call it a hack… once a WordPress upgrade comes out, I’m going to have to re-edit those files. I don’t like doing that – but until I can put this into some kind of plugin, that’s the only choice I have. If the spammers get smart enough, I can rename the variable and ask for a different number.
Pingback: Wolfey’s Weblog » A Site, a Script, a Stand, and So On