Fix checking for whether WP_User object is actually a user. props filosofo, fixes #13903 for 3.0.
git-svn-id: http://svn.automattic.com/wordpress/branches/3.0@15403 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ea8f1e0f32
commit
6bd16888b1
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue