The get_comment_author_email_link() WordPress PHP function returns the HTML email link to the author of the current comment.
Usage
get_comment_author_email_link( $linktext, $before, $after, $comment );
Parameters
$linktext
(string) Optional: Text to display instead of the comment author’s email address. Default: ”$before
(string) Optional: Text or HTML to display before the email link. Default: ”$after
(string) Optional: Text or HTML to display after the email link. Default: ”$comment
(int|WP_Comment) Optional: Comment ID or WP_Comment object. Default is the current comment. Default: null
More information
See WordPress Developer Resources: get_comment_author_email_link()
Examples
Display comment author’s email link with custom text
This example displays a custom text link for the comment author’s email address.
echo get_comment_author_email_link( 'Email Author', '<span class="email-link">', '</span>' );
Display comment author’s email link with the author’s name
This example displays the comment author’s name as the link text.
$author_name = get_comment_author(); echo get_comment_author_email_link( $author_name );
Display comment author’s email link with a custom icon
This example displays a custom icon before the email link.
echo get_comment_author_email_link( 'Email Author', '<span class="email-link"><i class="icon-email"></i> ' , '</span>' );
Display comment author’s email link for a specific comment ID
This example displays the email link for a specific comment ID.
$comment_id = 42; echo get_comment_author_email_link( 'Email Author', '', '', $comment_id );
Display comment author’s email link with custom HTML
This example displays the email link within a custom HTML structure.
echo get_comment_author_email_link( 'Email Author', '<div class="email-container"><span>Email: </span>', '</div>' );