WordPress.org

Make WordPress Core

Changeset 14302


Ignore:
Timestamp:
04/29/2010 06:24:18 PM (8 years ago)
Author:
ryan
Message:

Reset the global current_user object when the current user is changed.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/meta.php

    r14179 r14302  
    6262    // users cache stores usermeta that must be cleared.
    6363    if ( 'user' == $meta_type )
    64         wp_cache_delete($object_id, 'users');
     64        clean_user_cache($object_id);
    6565
    6666    do_action( "added_{$meta_type}_meta", $wpdb->insert_id, $object_id, $meta_key, $meta_value );
     
    125125    // users cache stores usermeta that must be cleared.
    126126    if ( 'user' == $meta_type )
    127         wp_cache_delete($object_id, 'users');
     127        clean_user_cache($object_id);
    128128
    129129    do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $meta_value );
  • trunk/wp-includes/user.php

    r14196 r14302  
    875875 */
    876876function clean_user_cache($id) {
     877    global $current_user;
     878
    877879    $user = new WP_User($id);
     880
     881    // If the current user changed, reset the current_user global.Œ
     882    if ( isset($current_user) && $current_user->ID == $id ) {
     883        $current_user->ID = -1; // Force wp_set_current_user to reset.
     884        error_log(" Resetting current user ");
     885        wp_set_current_user($id);
     886    }
    878887
    879888    wp_cache_delete($id, 'users');
Note: See TracChangeset for help on using the changeset viewer.