Advertisements

get_comment_author

Definition:
function get_comment_author( $comment_ID = 0 ) {}

Retrieve the author of the current comment.
If the comment has an empty comment_author field, then ‘Anonymous’ person is assumed.

Parameters

  • int $comment_ID: The ID of the comment for which to retrieve the author. Optional.

Return values

returns:The comment author

Defined filters

  • get_comment_author
    apply_filters('get_comment_author', $author)

Source code

function get_comment_author( $comment_ID = 0 ) {

	$comment = get_comment( $comment_ID );

	if ( empty($comment->comment_author) ) {

		if (!empty($comment->user_id)){

			$user=get_userdata($comment->user_id);

			$author=$user->user_login;

		} else {

			$author = __('Anonymous');

		}

	} else {

		$author = $comment->comment_author;

	}

	return apply_filters('get_comment_author', $author);

}

1290

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: