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

---

# get_comment_author_IP( int|WP_Comment $comment_id ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#changelog)

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

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_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 get the author’s IP address.
 Default current comment.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#return)󠁿

 string Comment author’s IP address, or an empty string if it’s not available.

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

    ```php
    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
    }
    ```

[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#L319)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment-template.php#L319-L333)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_comment_author_ip/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_comment_author_IP’, string $comment_author_ip, string $comment_id, WP_Comment $comment )](https://developer.wordpress.org/reference/hooks/get_comment_author_ip/)

Filters the comment author’s returned IP address.

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

| Uses | Description | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

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

Retrieves comment data given a comment ID or comment object.

  |

| Used by | Description | 
| [WP_Comments_List_Table::column_author()](https://developer.wordpress.org/reference/classes/wp_comments_list_table/column_author/)`wp-admin/includes/class-wp-comments-list-table.php` |  | 
| [comment_author_IP()](https://developer.wordpress.org/reference/functions/comment_author_ip/)`wp-includes/comment-template.php` |

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

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_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. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

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