Skip to:
Content

BuddyPress.org

Changeset 11817


Ignore:
Timestamp:
01/25/2018 07:44:49 PM (7 years ago)
Author:
dcavins
Message:

Change the display name WP/BP sync hook.

Instead of firing the display name synchronization routine on the general hook xprofile_updated_profile, which is run when the profile screen forms are submitted, use the lower level hook xprofile_data_after_save which is run when a profile field is updated. This catches more cases where we'd like the sync to run, like programatically updating the xprofile field.

See #7661.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r11705 r11817  
    838838    wp_update_user( array( 'ID' => $user_id, 'display_name' => $fullname ) );
    839839}
    840 add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
    841840add_action( 'bp_core_signup_user',      'xprofile_sync_wp_profile' );
    842841add_action( 'bp_core_activated_user',   'xprofile_sync_wp_profile' );
     
    862861add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 10, 3 );
    863862
     863/**
     864 * Update the WP display, last, and first name fields when the xprofile display name field is updated.
     865 *
     866 * @since 3.0.0
     867 *
     868 * @param BP_XProfile_ProfileData $data Current instance of the profile data being saved.
     869 */
     870function xprofile_sync_wp_profile_on_single_field_set( $data ) {
     871   
     872    if ( bp_xprofile_fullname_field_id() !== $data->field_id ) {
     873        return;
     874    }
     875
     876    xprofile_sync_wp_profile( $data->user_id );
     877}
     878add_action( 'xprofile_data_after_save', 'xprofile_sync_wp_profile_on_single_field_set' );
    864879
    865880/**
Note: See TracChangeset for help on using the changeset viewer.