• Resolved itsdivin

    (@itsdivin)


    Hello,

    Is there a way to change the Display name for the members to be their USERNAMES. Most of the members wish to use their USERNAMES, not their First Names. I thought I could somehow edit that in the registration form, but I have not found that form or the means to edit it.

    Maybe a snippet?

    I did check https://kainelabs.ticksy.com/articles/. Nothing about changing Display Name to be Username.

    Thanks

    • This topic was modified 3 years, 10 months ago by itsdivin.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Youzify

    (@kainelabsteam)

    Hello @itsdivin,

    Thanks for using our plugin.

    Please try using this snippet below:

    <?php
    /**
     * Change user display name to username.
     */
    function yzc_change_bp_display_name_to_username( $display_name, $user_id ) {
        // Get User Data.
        $user = get_userdata( $user_id );
        return $user->user_login ;
    }
    
    add_filter( 'bp_core_get_user_displayname', 'yzc_change_bp_display_name_to_username', 10, 2 );
    
    /**
     * Change user full name to username.
     */
    function yzc_change_bp_full_name_to_username( $display_name ) {
        $bp = buddypress();
        return isset( $bp->displayed_user->userdata->user_login ) ? $bp->displayed_user->userdata->user_login : '';
    }
    
    add_filter( 'bp_displayed_user_fullname', 'yzc_change_bp_full_name_to_username', 10 );
    
    /**
     * Change user first name to username.
     */
    function yzc_change_bp_first_name_to_username( $first_name ) {
        // Get User Data.
        $user = get_userdata( bp_loggedin_user_id() );
        return $user->user_login ;
    }
    
    add_filter( 'bp_get_user_firstname', 'yzc_change_bp_first_name_to_username', 10, 2 );

    Please add it to the file “bp-custom.php” in the path “wp-content/plugins”.

    Ps: if you didn’t find the file “bp-custom.php”, just create a new one.

    Let me know if it worked fine for you ??

    You are welcome.

    Best Regards, KaineLabs Team.

    Thread Starter itsdivin

    (@itsdivin)

    Thank you for the speedy response. However, that snippet caused a critical error. Appreciate your support.

    Plugin Support Youzify

    (@kainelabsteam)

    Oh!

    Please enabled debugger and let me know the error message that you see as it might be added incorrectly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change DISPLAY NAME to be the USERNAME’ is closed to new replies.