comment_author
云策文档标注
概述
comment_author 是一个 WordPress 过滤器钩子,用于在显示评论作者名称时进行过滤。它允许开发者修改评论作者的用户名,并提供了评论 ID 作为参数。
关键要点
- 过滤器钩子名称为 comment_author,用于过滤评论作者名称的显示。
- 参数包括 $comment_author(评论作者的用户名)和 $comment_id(评论 ID 作为数字字符串)。
- 在 WordPress 4.1.0 版本中增加了 $comment_id 参数,最初在 1.2.0 版本引入。
- 与 comment_author() 函数相关,该函数用于显示当前评论的作者。
代码示例
echo apply_filters( 'comment_author', $comment_author, $comment->comment_ID );
原文内容
Filters the comment author’s name for display.
Parameters
$comment_authorstring-
The comment author’s username.
$comment_idstring-
The comment ID as a numeric string.
Source
echo apply_filters( 'comment_author', $comment_author, $comment->comment_ID );