Preventing Comment Spam in WordPress

Not hours after I launched this and another blog, a whole series of comment spam came flooding in – You know, the usual sort: Casinos, pharmaceuticals, porn, and more.

So in an effort to combat this, I have made it a requirement for anyone who wishes to post to have cookies enabled in their browser.

And if you use WordPress, here is the code I used:

Paste the following on the first line before ‘require(‘header.php’)’ in index.php

setcookie ("hell_no_jerky",time(), time()+36000);

Now, in wp-comments-post.php go to line 51 or so and paste this:

if (!isset($_COOKIE['hell_no_jerky'])) {
die('You need to have cookies enabled to post comments here. This is to prevent malicious bastards running automated scripts from spamming the comment sections with useless links to websites about Hair Loss, gambling, and Russian Teen Mud Wrestling.');

What are these guys thinking, anyway? Google PageRank is dead. They would be better off searching for relevant backlinks and working on strong anchor text.


Kyle wrote 97 posts

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.