Fix checking for whether WP_User object is actually a user. props filosofo, fixes #13903 for trunk.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-07-13 21:27:05 +00:00
parent 5fb64228d8
commit 113a26770f
3 changed files with 7 additions and 7 deletions

View File

@ -265,7 +265,7 @@ switch ( $_GET['action'] ) {
reset( $newroles ); reset( $newroles );
foreach ( (array) $newroles as $userid => $role ) { foreach ( (array) $newroles as $userid => $role ) {
$user = new WP_User( $userid ); $user = new WP_User( $userid );
if ( ! $user ) if ( empty( $user->ID ) )
continue; continue;
$user->for_blog( $id ); $user->for_blog( $id );
$user->set_role( $role ); $user->set_role( $role );

View File

@ -1112,7 +1112,7 @@ function author_can( $post, $capability ) {
$author = new WP_User( $post->post_author ); $author = new WP_User( $post->post_author );
if ( empty( $author ) ) if ( empty( $author->ID ) )
return false; return false;
$args = array_slice( func_get_args(), 2 ); $args = array_slice( func_get_args(), 2 );

View File

@ -209,7 +209,7 @@ 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) || !$user->ID ) if ( empty( $user->ID ) )
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) ) {
@ -253,6 +253,9 @@ 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 ) )
return new WP_Error('user_does_not_exist', __('That user does not exist.'));
$user->remove_all_caps(); $user->remove_all_caps();
$blogs = get_blogs_of_user($user_id); $blogs = get_blogs_of_user($user_id);
@ -1326,10 +1329,7 @@ function is_user_spammy( $username = 0 ) {
} }
$u = new WP_User( $user_id ); $u = new WP_User( $user_id );
if ( $u->spam == 1 ) return ( isset( $u->spam ) && $u->spam == 1 );
return true;
return false;
} }
function update_blog_public( $old_value, $value ) { function update_blog_public( $old_value, $value ) {