Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show nickname instead of username


  • enkoes
    Participant

    @enkoes

    Hi, I would like to display nickname (and not username) in the whole bbpress forum.

    For topics list, I modified the code from a previous topic Show username instead of full name / display name and it works well so far.

    See https://paste.pics/MVA62

    The modified codes that I use is as follows:

    add_filter( 'bbp_get_reply_author_display_name' , 'rew_reply_change_to_nickname', 10 , 2 ) ;
    
    function rew_reply_change_to_nickname ($author_name, $reply_id) {
    	// Get the author ID
    	$author_id = bbp_get_reply_author_id( $reply_id );
    	$nickname = um_get_display_name( $author_id );
    return $nickname ;
    }
    
    add_filter( 'bbp_get_topic_author_display_name' , 'rew_topic_change_to_nickname', 10 , 2 ) ;
    
    function rew_topic_change_to_nickname ($author_name, $topic_id) {
    	// Get the author ID
    	$author_id = bbp_get_topic_author_id( $topic_id );
    	$nickname = um_get_display_name( $author_id );
    return $nickname ;
    }

    Note: I use Ultimate Member (UM) plugin to display user details.

    However, when comes to user profile, I’m struggling on how to force display nickname right above the avatar. Hope you can help me with that.

    See https://paste.pics/MVA6A

    Note: It’s very tedious to modify “display name publicly as” from the WordPress dashboard for every registered user. Thus hopefully codes may well do the job for me.

Viewing 5 replies - 1 through 5 (of 5 total)

  • wpturk
    Participant

    @wpturk

    A link to your website/forum can be helpful. Most probably, this header is coming from your theme.


    enkoes
    Participant

    @enkoes

    Hi, here is my test site. Still under construction.

    I found that most of the time WordPress display correctly in “display name publicly as” using NICKNAME. But there are times where it displays USERNAME in “display name publicly as” even though users have already registered their nickname in Ultimate Member profile.


    wpturk
    Participant

    @wpturk

    As I guessed, it’s coming from your theme

    You can try this: (it’s not tested)

    function aa_profile_title ( $title, $id ) {
    
            if ( bbp_is_single_user_profile() && empty(get_post_type($id)) ) {
    
                    $author_id = bbp_get_displayed_user_field('ID');
                    $nickname = um_get_display_name( $author_id );
                    $title = $nickname;
            }
            return $title;
    }       
    add_filter( 'the_title', 'aa_profile_title', 10, 2);

    enkoes
    Participant

    @enkoes

    Brilliant! Thanks for the codes. Just tested and it works like a charm! 😀


    wpturk
    Participant

    @wpturk

    you are welcome 👍

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar