get_comment_author()
Gets the name of the comment author. If the "author name" (comment_author) field is empty, the function will return: "Anonymous" (__('Anonymous')). The function is intended for use in the comment loop.
Uses: get_comment()
Used By: get_comment_author_link(), comment_author()
Hooks from the function
Returns
String. The name of the comment author.
Usage
$author = get_comment_author( $comment_ID );
- $comment_ID(int/object)
- ID or object of the comment whose author name needs to be retrieved.
Examples
#1 Get the name of the author of the current comment in the loop
echo get_comment_author( $comment_ID ); //> Eugene
Changelog
| Since 1.5.0 | Introduced. |
| Since 4.4.0 | Added the ability for $comment_id to also accept a WP_Comment object. |