Basically, any plugin that automatically deletes or puts in moderation a comment does so by changing the comment that has already been in the data base (for a split second).
Unfortunately with WordPress 1.2, you cannot prevent the “Comment posted” e-mail from going out just by using a plugin. This has been remedied in WordPress 1.3
Using WordPress 1.3, it would be trivial to make a plugin that deletes comments that are hit by the blacklist. I’m not sure it’s a great idea, unless you really really trust your blacklist, but it could be done.
Yesterday I got hit with a lot of comment spam and got tired of having to delete each one of them, so I came up with this patch.
In wp-comments-post.php, add the following code
$words = array (
"golimar.com",
"levitra",
"tramadol",
"cialis",
"fioricet",
"phentermine",
"viagra",
);
foreach ($words as $word) {
$word = trim($word);
$pattern = "#$word#i";
if (preg_match($pattern,$comment) || preg_match($pattern,$url)) {
die ("You are not allowed to post comments, spammer.");
}
Before the line:
$wpdb->query("INSERT INTO $tablecomments
(comment_post_ID, comment_author, comment_author_email, comment_author_url,
How can I convert this to a plugin?
P.S. you can change that array as necessary to list any words that only appear in spam, such as domain names.
you can probably model your plugin after laughinglizard’s three strikes plugin. it’s the only comment spam plugin that i’ve seen to prevent spam comments from hitting the database.
Thread Starter
stevem
(@stevem)
Great! Three strikes looks like just the sort of thing I am after. The URL decode function in it is an excellent idea. Will give it a go.
Three strikes did not work for me. For some reason it changed my comment submit button link to go to fbi.gov. I had to deactivate the plugin. I like the code that was provided above by Mike3k.
That might be something that I might just go ahead and add.
Comment spam sucks!
Thread Starter
stevem
(@stevem)
It works well for me. The fbi.gov (which you can change in the threestrikes file) should only be triggered when it thinks the comment is spam
I’ve converted it to a plugin, which can be downloaded here.
Anonymous
Cool plugin!
Just a suggestion, would it be possible to integrate the plugin with WP Blacklist such that $spamwords automatically uses the ones already in WP Blacklist (or the ones already specified in WP’s built-in spamword list?) This would save the effort of having to maintain 2-3 spamword blacklists.