xprofile_override_user_fullnames()

Replace the displayed and logged-in users fullnames with the xprofile name, if required.

Description

The Members component uses the logged-in user’s display_name to set the value of buddypress()->loggedin_user->fullname. However, in cases where profile sync is disabled, display_name may diverge from the xprofile fullname field value, and the xprofile field should take precedence.

Runs at bp_setup_globals:100 to ensure that all components have loaded their globals before attempting any overrides.

Source

File: bp-xprofile/bp-xprofile-functions.php

730
731
732
733
734
735
736
737
738
739
740
741
742
743
function xprofile_override_user_fullnames() {
    // If sync is enabled, the two names will match. No need to continue.
    if ( ! bp_disable_profile_sync() ) {
        return;
    }
 
    if ( bp_loggedin_user_id() ) {
        buddypress()->loggedin_user->fullname = bp_core_get_user_displayname( bp_loggedin_user_id() );
    }
 
    if ( bp_displayed_user_id() ) {
        buddypress()->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() );
    }
}

Changelog

Changelog
Version Description
BuddyPress 2.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.