Filter hook 'comment_author'

in WP Core File wp-includes/comment-template.php at line 82

View Source

comment_author

Filter Hook
Description
Filters the comment author's name for display.

Hook Information

File Location wp-includes/comment-template.php View on GitHub
Hook Type Filter
Line Number 82

Hook Parameters

Type Name Description
string $comment_author The comment author's username.
string $comment_id The comment ID as a numeric string.

Usage Examples

Basic Usage
<?php
// Hook into comment_author
add_filter('comment_author', 'my_custom_filter', 10, 2);

function my_custom_filter($comment_author, $comment_id) {
    // Your custom filtering logic here
    return $comment_author;
}

Source Code Context

wp-includes/comment-template.php:82 - How this hook is used in WordPress core
<?php
  77  	 * @since 4.1.0 The `$comment_id` parameter was added.
  78  	 *
  79  	 * @param string $comment_author The comment author's username.
  80  	 * @param string $comment_id     The comment ID as a numeric string.
  81  	 */
  82  	echo apply_filters( 'comment_author', $comment_author, $comment->comment_ID );
  83  }
  84  
  85  /**
  86   * Retrieves the email of the author of the current comment.
  87   *

PHP Documentation

<?php
/**
	 * 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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/comment-template.php
Related Hooks

Related hooks will be displayed here in future updates.