钩子文档

comment_form_logged_in

💡 云策文档标注

概述

comment_form_logged_in 是一个 WordPress 过滤器钩子,用于自定义评论表单中已登录用户的消息显示。它允许开发者修改或替换默认的“已登录为 [用户]”消息、编辑个人资料链接和退出登录链接的 HTML 输出。

关键要点

  • 这是一个过滤器钩子,用于过滤评论表单的已登录消息。
  • 接收三个参数:$args_logged_in(HTML 字符串)、$commenter(数组)和 $user_identity(字符串)。
  • 在 comment_form() 函数中被调用,用于输出评论表单。
  • 自 WordPress 3.0.0 版本引入。

代码示例

echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );

📄 原文内容

Filters the ‘logged in’ message for the comment form for display.

Parameters

$args_logged_instring
The HTML for the ‘logged in as [user]’ message, the Edit profile link, and the Log out link.
$commenterarray
An array containing the comment author’s username, email, and URL.
$user_identitystring
If the commenter is a registered user, the display name, blank otherwise.

Source

echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );

Changelog

Version Description
3.0.0 Introduced.