Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Display WP Username by default without Plugin

@sr3

Participant

Thanks, I only needed to override the author name in blog post comments, so I searched for the related code in the plugin, modified it and added it to my functions.php in my child theme. Now the username is displayed instead of the full name 🙂

function sr_get_comment_author( $author ) {
	global $bp, $comment;

	if( $comment->user_id) {
		$user=get_userdata($comment->user_id);
		echo $user->user_nicename;
	} else {
		return $author;
	}
}
add_filter( 'get_comment_author', 'sr_get_comment_author' );
Skip to toolbar