How To Prevent Commenters From Using Your eMail
Download my (first!) plugin WP Protect Author Email
(tested with WP 2.6.2 up to 2.7.1).
It actually uses the “preprocess_comment” filter of WordPress to check the commenters eMail – thus making it unnecessary to change any core files (like explained below)!
All you have to do is unzip the file, open it with a text editor, look for “$wp_pae_email” and put in the address that should be protected. Then save and upload this file to your wp-content/plugins/ directory, activate it via the admin panel – and see if it is working. Any feedback is welcome!
WordPress does not provide any function that would check the commenter’s eMail against e.g. the blog owner’s eMail. That way, anybody could use the admin’s name and eMail to leave a comment in the name of the blog owner. Since these blog owner’s comments are often highlighted, this impersonation is quite crucial.
Here is a way to disallow using a distinct eMail without being logged in:
- Open wp-comments-post.php from the WP root directory.
- Search for the following code (line 53 in WP 2.6.2):
if ( get_option('comment_registration') ) wp_die( __('Sorry, you must be logged in to post a comment.') ); - After those lines, insert this and put in the eMail that should be checked (repeat these lines if you want several eMails to be checked):
if ( strtolower($comment_author_email) == strtolower('email@to-be-check.ed') ) wp_die( __('Sorry, but you must be logged in to use that email. Nice try, though...
') );
Note:
If you are using Filosofo Comments Preview, you have to open that plugin file and do the same changes. The same would be necessary for any plugin that bypasses wp-comments-post.php.
Another note:
I wonder if I could use the “preprocess_comment” filter to add this functionality, so that the core WordPress files do not have to be touched.
Happy note:
Eureka! Bingo! Works! My first plugin!
Inspired by the article Prevent author impersonation in WordPress comments.
The post ends here. Wanna leave a response? Have Your Say!
You can also subscribe to comments without commenting.
BTW: This post has comments.
Next post: Firebug And The Mysterious “Components Is Not Defined”
Previous post: Show Some Love To Your Readers With CommentLUV
Trackback URI | Comments RSS | Permalink








Comment
#1
I’d never considered this before. Thanks for the tip – and the plugin.
Clare recently posted: 3 perfect Christmas gift ideas for your wife
Comment
#2
Wouldn’t this presuppose that you are using the Highlight Author Comment plugin?
I love seeing geeks in action. Ask Andy.
witchypoo recently posted: Mining the Search Strings
Comment
#3
@witchypoo:
Actually, you don’t have to use the “Highlight Author Comment” plugin, it is easy to implement this feature into your comment template, see this post. And even if the comment is not highlighted, it is still annoying if someone uses your name, isn’t it?