Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to configure the comments screen in the backend to fit my project. I've already been able to take a first step by resolving this question:

Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins

Now I'd like the post author viewing all the comments received to be unable to see the email account of the commenter. I'm a bit afraid that some of the authors could create some posts just to receive tons of comments and be able to see all the email accounts in his backend to use them for spamming purposes.

Is it possible to keep the email account of the commenter only to be viewable by the admin? Thanks!

I've been looking for hours online but the only kind of plugin I found is 6 years old and is not working

 /*
 Plugin Name: Erase Commenter Details
 Plugin URI: http://wordpress.org/support/topic/143772
 Description: Removes IP, e-mail and URL of comment authors from Comments admin when viewed by 'contributors.'
 Version: R1
 Author: Kaf Oseo
 Author URI: http://szub.net

Copyright (c) 2007 Kaf Oseo (http://szub.net)
Erase Commenter Details is released under the GNU General Public License
http://www.gnu.org/licenses/gpl.txt

This is a WordPress plugin (http://wordpress.org).

*/

function szub_erase_commenter_details($text) {
if( !current_user_can('publish_posts') ) {
    $patterns = array('/ \| <a href=\'.*\' rel=\'external\'>.*<\/a>/', '/ \| ' . __('IP') . ': <a href=.*<\/a>/', '/ \| <a href=\'mailto:.*<\/a>/', '/<th scope="col">(' . __('E-mail') . '|' . __('IP') . ')<\/th>/', '/<td>(<a href=(\'mailto|"edit-comments\.php).*<\/a>)?<\/td>/');
    $text = preg_replace($patterns, '', $text);
}
return $text;
}

if( strpos($_SERVER['REQUEST_URI'], 'wp-admin/edit-comments.php') ) {
ob_start('szub_erase_commenter_details');
}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

There is a filter 'comment_email'. Hook into that filter after the action 'load-edit-comments.php' and hide the email:

add_action( 'load-edit-comments.php', 't5_hide_commenter_email' );

function t5_hide_commenter_email()
{
    if ( ! current_user_can( 'manage_options' ) )
        add_filter( 'comment_email', '__return_false' );
}
share|improve this answer
    
Great! It works perfectly. Thanks for your time. –  user27309 Mar 26 '13 at 14:24
    
@user27309 See my update, I made it even simpler. :) –  toscho Mar 26 '13 at 14:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.