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
This commit is contained in:
markjaquith 2011-02-03 00:17:30 +00:00
parent 790f28fbe1
commit c08a6a4044

View File

@ -209,8 +209,10 @@ function add_user_to_blog( $blog_id, $user_id, $role ) {
$user = new WP_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.')); return new WP_Error('user_does_not_exist', __('That user does not exist.'));
}
if ( !get_user_meta($user_id, 'primary_blog', true) ) { if ( !get_user_meta($user_id, 'primary_blog', true) ) {
update_user_meta($user_id, 'primary_blog', $blog_id); 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); // wp_revoke_user($user_id);
$user = new WP_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.')); return new WP_Error('user_does_not_exist', __('That user does not exist.'));
}
$user->remove_all_caps(); $user->remove_all_caps();