diff --git a/wp-admin/ms-edit.php b/wp-admin/ms-edit.php index d826e0df48..5f6af9d1c2 100644 --- a/wp-admin/ms-edit.php +++ b/wp-admin/ms-edit.php @@ -265,7 +265,7 @@ switch ( $_GET['action'] ) { reset( $newroles ); foreach ( (array) $newroles as $userid => $role ) { $user = new WP_User( $userid ); - if ( ! $user ) + if ( empty( $user->ID ) ) continue; $user->for_blog( $id ); $user->set_role( $role ); diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 22974b6f49..cb762e73cb 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -1112,7 +1112,7 @@ function author_can( $post, $capability ) { $author = new WP_User( $post->post_author ); - if ( empty( $author ) ) + if ( empty( $author->ID ) ) return false; $args = array_slice( func_get_args(), 2 ); diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 8f2c6b800c..2b548621b0 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -209,7 +209,7 @@ function add_user_to_blog( $blog_id, $user_id, $role ) { $user = new WP_User($user_id); - if ( empty($user) || !$user->ID ) + if ( empty( $user->ID ) ) return new WP_Error('user_does_not_exist', __('That user does not exist.')); if ( !get_user_meta($user_id, 'primary_blog', true) ) { @@ -253,6 +253,9 @@ 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 ) ) + return new WP_Error('user_does_not_exist', __('That user does not exist.')); + $user->remove_all_caps(); $blogs = get_blogs_of_user($user_id); @@ -1326,10 +1329,7 @@ function is_user_spammy( $username = 0 ) { } $u = new WP_User( $user_id ); - if ( $u->spam == 1 ) - return true; - - return false; + return ( isset( $u->spam ) && $u->spam == 1 ); } function update_blog_public( $old_value, $value ) {