钩子文档

get_comment_author_IP

💡 云策文档标注

概述

get_comment_author_IP 是一个 WordPress 过滤器钩子,用于修改评论作者返回的 IP 地址。它允许开发者在获取评论作者 IP 时进行自定义处理。

关键要点

  • 钩子名称为 get_comment_author_IP,用于过滤评论作者的 IP 地址。
  • 接受三个参数:$comment_author_ip(IP 地址字符串)、$comment_id(评论 ID 字符串)和 $comment(WP_Comment 对象)。
  • 在 WordPress 4.1.0 版本中新增了 $comment_id 和 $comment 参数,最初在 1.5.0 版本引入。
  • 与 get_comment_author_IP() 函数相关,该函数用于检索当前评论作者的 IP 地址。

代码示例

return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );

📄 原文内容

Filters the comment author’s returned IP address.

Parameters

$comment_author_ipstring
The comment author’s IP address, or an empty string if it’s not available.
$comment_idstring
The comment ID as a numeric string.
$commentWP_Comment
The comment object.

Source

return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase

Changelog

Version Description
4.1.0 The $comment_id and $comment parameters were added.
1.5.0 Introduced.