get_comment_author_linkfilter-hookWP 1.5.0

Allows you to change the link to the commenter's website returned by get_comment_author_link().

Usage

add_filter( 'get_comment_author_link', 'wp_kama_get_comment_author_link_filter', 10, 3 );

/**
 * Function for `get_comment_author_link` filter-hook.
 * 
 * @param string $comment_author_link The HTML-formatted comment author link. Empty for an invalid
 *                                    URL.
 * @param string $comment_author      The comment author's username.
 * @param string $comment_id          The comment ID as a numeric string.
 *
 * @return string
 */
function wp_kama_get_comment_author_link_filter( $comment_author_link, $comment_author, $comment_id ){
	// filter...
	return $comment_author_link;
}
$return(string)
The link to the commenter's website in HTML format (<a></a>) if it was specified and is valid. Otherwise, the comment author's name.
$author(string)
The comment author's name retrieved by get_comment_author().
$comment_ID(integer)
The comment ID.

Examples

#1 Change the link so that it opens in a new tab.

Add the target='_blank' attribute to the link:

add_filter( 'get_comment_author_link', 'add_target_blank_comment_author_link' );
function add_target_blank_comment_author_link( $return ) {
	$search  = 'external nofollow\'';
	$replace = 'external nofollow noreferrer\' target=\'_blank\'';

	return str_replace( $search, $replace, $return );
}

Notes

  • The $author and $comment_ID parameters were added in version 4.1.0.

Changelog

Since 1.5.0 Introduced.
Since 4.1.0 The $comment_author and $comment_id parameters were added.

Where the hook is called

get_comment_author_link()
get_comment_author_link
wp-includes/comment-template.php 293
return apply_filters( 'get_comment_author_link', $comment_author_link, $comment_author, $comment_id );

Where the hook is used in WordPress

Usage not found.