Modify column_author in WP_Comments_List_Table

This is how the email part is displayed by the WP_Comments_List::column_author() method:

/* This filter is documented in wp-includes/comment-template.php */
$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );

if ( ! empty( $email ) && '@' !== $email ) {
    printf( '<a href="https://wordpress.stackexchange.com/questions/258903/%1$s">%2$s</a><br />', esc_url( 'mailto:' . $email ), esc_html( $email ) );
}

so you’re most likely looking for the comment_email filter.

Update:

Here’s a hack to add a subject and body to the mailto part:

add_filter( 'comment_email', function( $email )
{
    // Target the edit-comments.php screen
    if( did_action( 'load-edit-comments.php' ) )
        add_filter( 'clean_url', 'wpse_258903_append_subject_and_body' );       

    return $email;
} );

function wpse_258903_append_subject_and_body( $url )
{
    // Only run once
    remove_filter( current_filter(), __FUNCTION__ );

    // Adjust to your needs:
    $args = [ 'subject' => 'hello', 'body' => 'world' ];

    // Only append to a mailto url
    if( 'mailto' === wp_parse_url($url, PHP_URL_SCHEME )  )
        $url .= '?' . build_query( $args );

    return esc_url( $url );
}

Note that this targets the first esc_url() after each time the comment_email filter is applied, on the edit-comments.php page.

We added a mailto check to make sure it’s for the email part.

Leave a Comment