Change comment author

comment_author

When you don’t want to show the comment author’s email, you would want to replace it with something else.

01
02
03
04
05
06
07
08
09
10
add_filter( 'comment_author', 'wpa_custom_comment_author', 10, 2 );
function wpa_custom_comment_author( $author, $commentID ) {
    $comment = get_comment( $commentID );
    $user = get_user_by( 'email', $comment->comment_author_email );
    if( !$user ):
        return $author;
    else:
        return substr( $comment->comment_author_email, 0,2 ) . '****';
    endif;
}