Compdigitec Labs

« | Home | »

WordPress author email blacklist patch

By admin | August 29, 2008

If you’ve ever needed to block a single comment spammer using multiple IPs, referrers and urls, but the same email, here’s a patch for WordPress 2.5. This patch is released under the GNU General Public License.

Add the following code to wp-comments-post.php after the line “$comment_content      = trim($_POST[‘comment’]);” (line 30 on v2.5):
// ****** Start of comment email patch by Compdigitec ******
$name = 'comment_author_email_blacklist.txt';
$blacklist_email = ''; // ** You can change the above blacklist file
$flag = true;
if(
file_exists($name) && is_readable($name)) {
$ble = trim(file_get_contents($name));
$blacklist_email = explode("\n",$ble);
foreach(
$blacklist_email as $value) {
if(
$comment_author_email == $value) {
$flag = false;
}
}
if(
$flag === false) {
wp_die(__('Sorry, you are on our spam blacklist and therefore can not post comments.'));
}
} else {
// Not readable.
echo __("<!-- Warning: Comment Email Blacklist could not be read. -->");
}
// ****** End of comment email patch by Compdigitec ******

Next, create a file called comment_author_email_blacklist.txt (or your custom filename if you changed it above). In the file, add your email addresses to blacklist, one per line. Don’t forget to add testblacklist@example.com to test it.

If the patch has been installed, log out if you are logged in as the site admin. Then go to any post and try to post a comment (make sure there is some content, even if it is nonsense) with the email as “testblacklist@example.com” (without the quotes). You should be confronted with the following dialog:
WordPress 2.5 with email blacklist patch denying comment posintg to a spammer
If you do, congratulations! You have successfully installed the WordPress author email patch by Compdigitec. You can now proceed to adding more blacklist emails to your blacklist.

Troubleshooting

If you found the patch for WordPress helpful or useful, please help Compdigitec by spreading the word. Also, please also take a look at our main site, our wiki and our forums. Don’t forget to subscribe to Compdigitec Labs for more intersting articles!

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Internet | 4 Comments »

4 Responses to “WordPress author email blacklist patch”

  1. ezineaerticles » Blog Archive » Wordpress author email blacklist patch Says:
    August 29th, 2008 at 19:12

    […] Original post by admin […]

  2. Extenze Says:
    August 18th, 2009 at 17:21

    Generally I do not post on blogs, but I would like to say that this post really forced me to do so! really nice post.

  3. qiuqiu99 Says:
    March 30th, 2024 at 00:26

    … [Trackback]

    […] Read More to that Topic: compdigitec.com/labs/2008/08/29/wordpress-author-email-blacklist-patch/ […]

  4. buy peyote buttons Says:
    April 4th, 2024 at 23:23

    … [Trackback]

    […] Read More to that Topic: compdigitec.com/labs/2008/08/29/wordpress-author-email-blacklist-patch/ […]

Comments