comment_author

Displays the author of the current comment.

Description

comment_author( (int) $comment_ID = 0 ); 

Parameters (1)

0. $comment_id — Optional. (int)
WP_Comment or the ID of the comment for which to print the author.

Usage

  1. if ( !function_exists( 'comment_author' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4. // Optional. WP_Comment or the ID of the comment for which to print the author. 
  5. // Default current comment. 
  6. $comment_id = -1; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = comment_author($comment_id); 
  10.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment-template.php  
  1. function comment_author( $comment_ID = 0 ) { 
  2. $comment = get_comment( $comment_ID ); 
  3. $author = get_comment_author( $comment ); 
  4.  
  5. /** 
  6. * Filters the comment author's name for display. 
  7. * @since 1.2.0 
  8. * @since 4.1.0 The `$comment_ID` parameter was added. 
  9. * @param string $author The comment author's username. 
  10. * @param int $comment_ID The comment ID. 
  11. */ 
  12. echo apply_filters( 'comment_author', $author, $comment->comment_ID );