Nov 22 2004

How Do I Deal With Comment Spam in Wordpress?

Category: Blogging, From My LifeJeremy Wright @ 8:50 am

I’ve been asked this a few times over the last little while. I don’t provide this post as a resource, but more as an “in case you were wondering”. There are better solutions, I’m sure, and more elegant ones, but this solution works for me.

1. Go to your WP Admin screen. Click the Options menu item. Select “Discussion” from the secondary navigation. Users must fill out name and email, and I block all comments with more than 2 links and approve them manually.
2. USE THE BLACKLIST functionality built into WP. Here’s my list:

nitin
loan
tax
bank
credit
debt
joe@aaa.com
dexatrim
diet
212.37.48.115
porn
adult
princeofprussia
clshi
ixm
smallbusinessbuddy
ozgression
64.254.209.254
dave@yahoo.com
headache
blackjack
texas-
online-
gaming-
casino
tramadol
-online
adipex
advicer
ambien
bllogspot
carisoprodol
casino
casinos
baccarrat
cialis
cwas
cyclen
cyclobenzaprine
day-trading
discreetordering
dutyfree
duty-free
fioricet
freenet-shopping
incest
levitra
macinstruct
meridia
online-gambling
paxil
phentermine
platinum-celebs
poker-chip
poze
prescription
soma
slot-machine
taboo
teen
tramadol
trim-spa
ultram
viagra
xanax
zolus
chatroom
blackjack

This deals with the default spammers as well as most of what I’ve come across.

3. Close all comments older than 30 days. 98% of comments are on older posts that have been thoroughly dug into Google’s index. Closing comments on these doesn’t reduce the amount of useful comments you get, since 99% of most people’s comments are on posts that are less than one week old. Here is the noddy code I use for this, I’ve inserted it in the wp-admin/post.php file, right at the top:

<?php

include (’../wp-config.php’);

$age_cutoff = ‘30 DAY’;

$cutoff_date = $wpdb->get_var (”SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL $age_cutoff), INTERVAL 1 DAY)”);

$wpdb->query (”UPDATE $tableposts SET comment_status = ‘closed’ WHERE post_date < '$cutoff_date' AND post_status = 'publish'");

?>

9 Responses to “How Do I Deal With Comment Spam in Wordpress?”

  1. A Random Act of Blogging » Commenting disabled… says:

    [...] oderation, but I would rather not have to moderate these large numbers of comments. So a solution that I found over at Ensight is to basically tu [...]

  2. Vinnie Garcia says:

    Have you installed the Spam Stopgap yet? If not, do so. It’s cut my comment spam down to zero over the past two weeks and allowed me to turn comment moderation off.

    About closing comments on old posts: I don’t really agree with it. I still get some good comments on older posts on my blog that prove helpful to others. If I were to cut them off I’d have no idea that anybody tried to add their opinion on a matter. I guess this one depends on the nature of your blog, but for my blog I don’t think it would do more good than harm.

  3. Jeremy C. Wright says:

    Well, I can’t remember the last time I got a comment on an old post. Also, these measures have reduced my comment spam from 300-500 a day to 1-2 a month.

  4. Wesley says:

    I’ve installed authimage and its worked pretty well. I haven’t received any comment spam since I’ve started using it.

  5. Danne says:

    I guess I’ve been extremely fortunate because I’ve never gotten comment spam (ducks for cover), so I’ve never had the incentive to close out comments after a certain peroid. Actually, on one particular post I got a comment about it over a year later.

    Maybe I’m just not popular :( …or likely because spam bots look for MT and WP formats for easy access.

  6. Jim S says:

    I don’t get it… it doesn’t work for me

  7. JimSpot says:

    Test Blog
    I haven’t played with the WordPress test blog much at all lately. What I have been doing is fighting a…

  8. Jim S says:

    I’m talking about the auto-shut off for comments. I tried putting it into the WP-admin/post.php and I get a parse error when trying to login to the admin screen. It also doesn’t function at all.