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

---

# comment_author( int|WP_Comment $comment_id )

## In this article

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

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

Displays the author of the current comment.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/comment_author/?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.
 Default current comment.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/comment_author/?output_format=md#more-information)󠁿

If no name is provided (and “User must fill out name and email” is not enabled under
[Discussion Options](https://wordpress.org/support/article/settings-discussion-screen/)),
WordPress will assign “Anonymous” as comment author.

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

    ```php
    function comment_author( $comment_id = 0 ) {
    	$comment = get_comment( $comment_id );

    	$comment_author = get_comment_author( $comment );

    	/**
    	 * Filters the comment author's name for display.
    	 *
    	 * @since 1.2.0
    	 * @since 4.1.0 The `$comment_id` parameter was added.
    	 *
    	 * @param string $comment_author The comment author's username.
    	 * @param string $comment_id     The comment ID as a numeric string.
    	 */
    	echo apply_filters( 'comment_author', $comment_author, $comment->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#L68)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment-template.php#L68-L83)

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

 [apply_filters( ‘comment_author’, string $comment_author, string $comment_id )](https://developer.wordpress.org/reference/hooks/comment_author/)

Filters the comment author’s name for display.

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

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

Retrieves the author of the current comment.

  | 
| [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.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/comment_author/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/comment_author/?output_format=md#)

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

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/comment_author/?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/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/comment_author/?output_format=md#comment-content-1058)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/comment_author/#comment-1058)
 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%2F%23comment-1058)
    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%2F%23comment-1058)
 4. **Basic Example**
 5.     ```php
        <div>Comment by <?php comment_author(); ?>:</div>
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_author%2F%3Freplytocom%3D1058%23feedback-editor-1058)

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