comment_author_IP() WordPress Function

The comment_author_IP() function in WordPress is used to get the IP address of the comment author. This can be useful for many purposes, such as blocking IP addresses that are known to be spammy.

comment_author_IP( int|WP_Comment $comment_ID ) #

Displays the IP address of the author of the current comment.


Parameters

$comment_ID

(int|WP_Comment)(Optional) WP_Comment or the ID of the comment for which to print the author's IP address. Default current comment.


Top ↑

Source

File: wp-includes/comment-template.php

function comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	echo esc_html( get_comment_author_IP( $comment_ID ) );
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Added the ability for $comment_ID to also accept a WP_Comment object.
0.71Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More