« Geany – the ultimate IDE for programming | Home | The “Gtk-CRITICAL gtk_text_buffer_emit_insert assertion” warning in PHP-GTK2 »
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:
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
- “<!– Warning: Comment Email Blacklist could not be read. –>” appears when you view the source every time you post a comment. Self-explaining – you need to create your blacklist file or make your blacklist file readable.
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 | 5 Comments »
August 29th, 2008 at 19:12
[…] Original post by admin […]
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.
November 16th, 2024 at 12:12
… [Trackback]
[…] Find More on to that Topic: compdigitec.com/labs/2008/08/29/wordpress-author-email-blacklist-patch/ […]
November 28th, 2024 at 18:32
… [Trackback]
[…] Read More Information here to that Topic: compdigitec.com/labs/2008/08/29/wordpress-author-email-blacklist-patch/ […]
December 20th, 2024 at 20:33
… [Trackback]
[…] Find More Information here to that Topic: compdigitec.com/labs/2008/08/29/wordpress-author-email-blacklist-patch/ […]