Comments screen in backend, how to disable email address of commenter for non admins

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

Read More

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');
}

Related posts

Leave a Reply

1 comment

  1. 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' );
    }