Reset the global current_user object when the current user is changed.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
62a5269eed
commit
ec46abfe29
|
@ -61,7 +61,7 @@ function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique =
|
|||
wp_cache_delete($object_id, $meta_type . '_meta');
|
||||
// users cache stores usermeta that must be cleared.
|
||||
if ( 'user' == $meta_type )
|
||||
wp_cache_delete($object_id, 'users');
|
||||
clean_user_cache($object_id);
|
||||
|
||||
do_action( "added_{$meta_type}_meta", $wpdb->insert_id, $object_id, $meta_key, $meta_value );
|
||||
|
||||
|
@ -124,7 +124,7 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v
|
|||
wp_cache_delete($object_id, $meta_type . '_meta');
|
||||
// users cache stores usermeta that must be cleared.
|
||||
if ( 'user' == $meta_type )
|
||||
wp_cache_delete($object_id, 'users');
|
||||
clean_user_cache($object_id);
|
||||
|
||||
do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $meta_value );
|
||||
|
||||
|
|
|
@ -874,8 +874,17 @@ function update_user_caches(&$user) {
|
|||
* @param int $id User ID
|
||||
*/
|
||||
function clean_user_cache($id) {
|
||||
global $current_user;
|
||||
|
||||
$user = new WP_User($id);
|
||||
|
||||
// If the current user changed, reset the current_user global.Œ
|
||||
if ( isset($current_user) && $current_user->ID == $id ) {
|
||||
$current_user->ID = -1; // Force wp_set_current_user to reset.
|
||||
error_log(" Resetting current user ");
|
||||
wp_set_current_user($id);
|
||||
}
|
||||
|
||||
wp_cache_delete($id, 'users');
|
||||
wp_cache_delete($user->user_login, 'userlogins');
|
||||
wp_cache_delete($user->user_email, 'useremail');
|
||||
|
|
Loading…
Reference in New Issue