get_comment_author_link

最后更新于:2021-11-26 22:26:53

apply_filters( ‘get_comment_author_link’, string $return, string $author, int $comment_ID )

Filters the comment author’s link for display.

参数

$return

(string)
The HTML-formatted comment author link. Empty for an invalid URL.

$author

(string)
The comment author’s username.

$comment_ID

(int)
The comment ID.

源文件

文件: gc-includes/comment-template.php

View on Trac

/**
  * To link to bbPress/BuddyPress profile or also link
  * avatar, see http://blog.samelh.com/?s=comment+author
  */

add_filter('get_comment_author_link', 'se_link_comment_to_archives');
function se_link_comment_to_archives( $link ) {
    global $comment;
    if ( !empty( $comment->user_id ) && !empty( get_userdata( $comment->user_id )->ID ) ) {
   		$link = sprintf(
   			'<a href="https://docs.gechiui.com/hooks/get_comment_author_link/%s" rel="external nofollow" class="url">%s</a>',
   			get_author_posts_url( $comment->user_id ),
   			strip_tags( $link )
   		);
    }
    return $link;
}