get_comment_author_ip

函数
get_comment_author_ip ( $comment_ID = 0 )
参数
  • (int|WP_Comment) $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. Default current comment.
    Required:
返回值
  • (string) Comment author's IP address, or an empty string if it's not available.
定义位置
相关方法
get_comment_authorget_comment_author_linkget_comment_author_emailcomment_author_ipget_comment_author_url
引入
1.5.0
弃用
-

get_comment_author_ip: 这个函数返回评论的作者的IP地址。它需要一个参数,即$comment_ID,这是你想检索作者IP的评论的ID。

检索当前评论的作者的IP地址。

function get_comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$comment = get_comment( $comment_ID );

	/**
	 * Filters the comment author's returned IP address.
	 *
	 * @since 1.5.0
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
	 *
	 * @param string     $comment_author_ip The comment author's IP address, or an empty string if it's not available.
	 * @param string     $comment_ID        The comment ID as a numeric string.
	 * @param WP_Comment $comment           The comment object.
	 */
	return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
}

常见问题

FAQs
查看更多 >