If you don’t find a custom solution to this I just wanted to point out that plugin is built by @r-a-y, one of the BuddyPress core developers. I expect it should still work fine. As always, try it on a test install before adding to your live site.
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' );
You don’t need the globals.
You aren’t using $bp
and $comment
is passed in the filter hook.
apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment );
Try:
function sr_get_comment_author( $author, $comment_ID, $comment ) {
if ( isset( $comment->user_id ) ) {
$user = get_userdata($comment->user_id);
$author = $user->user_nicename;
}
return $author;
}
add_filter( 'get_comment_author', 'sr_get_comment_author', 1, 3 );