Dont stupid blogspammers have anything useful to do?
My blogs have moderated comments and its a pain to delete 50 per day!
(BTW: I changed the default radio button to be “Delete comment” )
So here is a very minor code change to blast them into oblivion with no effort on your part, after setting up your kill words.
– it also has a fix for a problem that should be handled elsewhere, but I don’t have time right now. Maybe someone else can do it.
First, add this function in wp-includes/functions.php
function zap_comment($author, $email, $url, $comment, $user_ip)
// moderation keys empty?
if (” == trim( get_settings(‘moderation_keys’) ) ) return false;
$words = explode(“\n”, get_settings(‘moderation_keys’) );
foreach ($words as $word)
$word = trim($word);
$pattern = “#$word#i”;
if(‘##i’ != $pattern) // ignore blank lines in the bad words list
if ( preg_match($pattern, $author) ) return true;
if ( preg_match($pattern, $email) ) return true;
if ( preg_match($pattern, $url) ) return true;
if ( preg_match($pattern, $comment) ) return true;
if ( preg_match($pattern, $user_ip) ) return true;
Then change the checkcomment code in wp-comments-post.php
if(check_comment($author, $email, $url, $comment, $user_ip))
$approved = 1;
if(zap_comment($author, $email, $url, $comment, $user_ip))
die( __(‘Stop spamming my blog, I just delete all your spam anyway.’) );
$approved = 0;
You can test this by visiting one of my blogs at
http://crossfirewar.com and posting a comment.
To trigger it, use the phrase “stupid blogspammers”
Hopefully someone will consider using this and adding another textarea for kill_keys, rather than using moderation_keys
- The topic ‘I hate blogspammers – this is how I kill them’ is closed to new replies.