Title: get_comment_author_email_link
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_comment_author_email_link( string $link_text = ”, string $before = ”, string $after = ”, int|WP_Comment $comment = null ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#changelog)

Returns the HTML email link to the author of the current comment.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#description)󠁿

Care should be taken to protect the email address and assure that email harvesters
do not capture your commenter’s email address. Most assume that their email address
will not appear in raw form on the site. Doing so will enable anyone, including 
those that people don’t want to get the email address and use it for their own means
good and bad.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#parameters)󠁿

 `$link_text`stringoptional

Text to display instead of the comment author’s email address.

Default:`''`

`$before`stringoptional

Text or HTML to display before the email link.

Default:`''`

`$after`stringoptional

Text or HTML to display after the email link.

Default:`''`

`$comment`int|[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
optional

Comment ID or [WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
object. Default is the current comment.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#return)󠁿

 string HTML markup for the comment author email link. By default, the email address
is obfuscated via the ['comment_email'](https://developer.wordpress.org/reference/hooks/comment_email/)
filter with [antispambot()](https://developer.wordpress.org/reference/functions/antispambot/).

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#source)󠁿

    ```php
    function get_comment_author_email_link( $link_text = '', $before = '', $after = '', $comment = null ) {
    	$comment = get_comment( $comment );

    	/**
    	 * Filters the comment author's email for display.
    	 *
    	 * Care should be taken to protect the email address and assure that email
    	 * harvesters do not capture your commenter's email address.
    	 *
    	 * @since 1.2.0
    	 * @since 4.1.0 The `$comment` parameter was added.
    	 *
    	 * @param string     $comment_author_email The comment author's email address.
    	 * @param WP_Comment $comment              The comment object.
    	 */
    	$comment_author_email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );

    	if ( ( ! empty( $comment_author_email ) ) && ( '@' !== $comment_author_email ) ) {
    		$display = ( '' !== $link_text ) ? $link_text : $comment_author_email;

    		$comment_author_email_link = $before . sprintf(
    			'<a href="%1$s">%2$s</a>',
    			esc_url( 'mailto:' . $comment_author_email ),
    			esc_html( $display )
    		) . $after;

    		return $comment_author_email_link;
    	} else {
    		return '';
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/comment-template.php#L188)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/comment-template.php#L188-L218)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘comment_email’, string $comment_author_email, WP_Comment $comment )](https://developer.wordpress.org/reference/hooks/comment_email/)

Filters the comment author’s email for display.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#related)󠁿

| Uses | Description | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_comment()](https://developer.wordpress.org/reference/functions/get_comment/)`wp-includes/comment.php` |

Retrieves comment data given a comment ID or comment object.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#)

| Used by | Description | 
| [comment_author_email_link()](https://developer.wordpress.org/reference/functions/comment_author_email_link/)`wp-includes/comment-template.php` |

Displays the HTML email link to the author of the current comment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_comment_author_email_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.6.0](https://developer.wordpress.org/reference/since/4.6.0/) | Added the `$comment` parameter. | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_comment_author_email_link%2F)
before being able to contribute a note or feedback.