Title: comment_author_IP
Published: April 25, 2014
Last modified: April 28, 2025

---

# comment_author_IP( int|WP_Comment $comment_id )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#wp--skip-link--target)

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#parameters)󠁿

 `$comment_id`int|[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
optional

[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/) or the
ID of the comment for which to print the author’s IP address.
 Default current comment.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment-template.php#L344)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment-template.php#L344-L346)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#related)󠁿

| Uses | Description | 
| [get_comment_author_IP()](https://developer.wordpress.org/reference/functions/get_comment_author_ip/)`wp-includes/comment-template.php` |

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

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Added the ability for `$comment_id` to also accept a [WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/) object. | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/comment_author_ip/?output_format=md#comment-content-1486)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/comment_author_ip/#comment-1486)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_author_ip%2F%23comment-1486)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_author_ip%2F%23comment-1486)
 4. **Displays comment author IP**
 5.     ```php
        Posted from: <?php comment_author_IP(); ?>
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_author_ip%2F%3Freplytocom%3D1486%23feedback-editor-1486)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_author_ip%2F)
before being able to contribute a note or feedback.