A level above Akismet – Prevent comment spam in wordpress

by Ankur Jain on January 28, 2009

stop-spam

Akismet is a proven way to prevent comment spam in wordpress powered blogs. It does a great job of sifting spam comments and redirecting them to the spam folder.

There is still a problem with this. Though spam get redirected to the appropriate folder but it unnecessarily clogs our MYSQL database. Moreover there is always a chance that among the hundreds of spam comments there is one good comment and unknowingly you might end up deleting that good comment as well, while cleaning up the folder.

I did some analysis on my spam comments (wordpress dashboard > comments > spam) and found that they mostly originate from 2-3 common IP’s. If I can get some way to automatically delete comments coming through those IP’s my problem would be partially solved(other spammers would still be there…grrr).

Here is a simple SQL script I wrote to do this:

DELETE FROM `wp_comments`
where `comment_author_IP` = ’66.159.18.9′ OR
`comment_author_IP` = ’84.19.188.218′;

Keep on adding the spammers IP’s that you see from your wordpress dashboard.

Now you can set up a  cron job that runs every night or every week or every fortnight (depending on your requrements). All your spam comments would get deleted automatically at a given interval.

Gozar!

{ 3 comments… read them below or add one }

Kurt Avish January 31, 2009 at 6:26 PM

Simple..but genius :-) Nice post. Spammers mostly use the same ip as many of them uses anonymous posting service to send spam.

Reply

Mr. I March 5, 2009 at 12:59 PM

Nice idea to block spam without any false positives and extra plugins. I love the fact that its very light!

Reply

ROW March 5, 2009 at 2:13 PM

Thanks Mr.I

Reply

Leave a Comment

Previous post:

Next post: