Skip to:
Content

BuddyPress.org

Changeset 14184


Ignore:
Timestamp:
12/29/2025 05:51:08 PM (7 weeks ago)
Author:
espellcaste
Message:

Fix for a "call to undefined function xprofile_get_field_data()" error at BP_LoggedIn_User.

Let us avoid an error when trying to get a logged-in user fullname, which relies on the XProfile Extended component. If this component is disabled, its functions are not loaded.

See #9276

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-loggedin-user.php

    r14070 r14184  
    108108
    109109            case 'fullname':
    110                 $current_user_id = get_current_user_id();
     110                $current_user_id      = get_current_user_id();
     111                $disable_profile_sync = bp_disable_profile_sync();
    111112
    112113                /**
    113                 * When profile sync is disabled, display_name may diverge from the xprofile
    114                 * fullname field value, and the xprofile field should take precedence.
    115                 */
     114                 * When profile sync is disabled, display_name may diverge from the xprofile
     115                 * fullname field value, and the xprofile field should take precedence.
     116                 */
    116117                $retval = '';
    117                 if ( bp_disable_profile_sync() ) {
     118                if ( $disable_profile_sync && bp_is_active( 'xprofile' ) ) {
    118119                    $retval = xprofile_get_field_data( bp_xprofile_fullname_field_name(), $current_user_id );
    119120                }
     
    122123                 * Common case: If BP profile and WP profiles are synced,
    123124                 * then we use the WP value.
    124                  * This is also used if the xprofile field data is preferred, but empty.
     125                 * This is also used if the xprofile field data is preferred, but empty or the component is disabled.
    125126                 */
    126                 if ( ! bp_disable_profile_sync() || ! $retval ) {
     127                if ( ! $disable_profile_sync || ! $retval ) {
    127128                    $retval = bp_core_get_user_displayname( $current_user_id );
    128129                }
     
    139140            default:
    140141                return isset( $this->{$key} ) ? $this->{$key} : null;
    141          }
     142        }
    142143    }
    143144
Note: See TracChangeset for help on using the changeset viewer.