From c08a6a40442b4b6f40a1a41cae804f7262aded2c Mon Sep 17 00:00:00 2001 From: markjaquith Date: Thu, 3 Feb 2011 00:17:30 +0000 Subject: [PATCH] restore_current_blog() in add_user_to_blog() and remove_user_from_blog() before early return, to avoid being stuck in a switched state. props mdawaffe. fixes #16444 for trunk. git-svn-id: http://svn.automattic.com/wordpress/trunk@17379 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-functions.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 9d727c9f48..16f5a05aa5 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -209,8 +209,10 @@ function add_user_to_blog( $blog_id, $user_id, $role ) { $user = new WP_User($user_id); - if ( empty( $user->ID ) ) + if ( empty( $user->ID ) ) { + restore_current_blog(); return new WP_Error('user_does_not_exist', __('That user does not exist.')); + } if ( !get_user_meta($user_id, 'primary_blog', true) ) { update_user_meta($user_id, 'primary_blog', $blog_id); @@ -269,8 +271,10 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') { // wp_revoke_user($user_id); $user = new WP_User($user_id); - if ( empty( $user->ID ) ) + if ( empty( $user->ID ) ) { + restore_current_blog(); return new WP_Error('user_does_not_exist', __('That user does not exist.')); + } $user->remove_all_caps();