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;
file_exists($name) && is_readable($name)) {
$ble = trim(file_get_contents($name));
$blacklist_email = explode("\n",$ble);
$blacklist_email as $value) {
$comment_author_email == $value) {
$flag = false;
$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 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 “” (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.


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: HTTP (Internet) | 2 Comments »

2 Responses to “WordPress author email blacklist patch”

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

    [...] Original post by admin [...]

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

    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.