Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/01/2016 08:32:46 PM (8 years ago)
Author:
djpaul
Message:

xprofile: remove direct SQL query when syncing BP profile to WP, and clear BP user cache.

When the user updates their profile name, and xprofile syncing is enabled (the default), we update the display_name property of the WordPress user. We remove the direct query to help prevent WordPress having a stale cache.

We also need to clear our own legacy user cache object so that bp_displayed_user_fullname returns accurate data.

Fixes #7050

File:
1 edited

Legend:

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

    r10825 r10857  
    828828    bp_update_user_meta( $user_id, 'last_name',  $lastname  );
    829829
    830     global $wpdb;
    831 
    832     $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
     830    wp_update_user( array( 'ID' => $user_id, 'display_name' => $fullname ) );
     831    wp_cache_delete( 'bp_core_userdata_' . $user_id, 'bp' );
    833832}
    834833add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
Note: See TracChangeset for help on using the changeset viewer.