diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index b493eee0d7..b6a495c932 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -459,7 +459,7 @@ class WP_User { * @since 2.0.0 * @access public * - * @param int|string $id User's ID + * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. * @param string $name Optional. User's username * @param int $blog_id Optional Blog ID, defaults to current blog. * @return WP_User @@ -477,6 +477,14 @@ class WP_User { ); } + if ( is_a( $id, 'WP_User' ) ) { + $this->init( $id->data, $blog_id ); + return; + } elseif ( is_object( $id ) ) { + $this->init( $id, $blog_id ); + return; + } + if ( ! empty( $id ) && ! is_numeric( $id ) ) { $name = $id; $id = 0; diff --git a/wp-includes/user.php b/wp-includes/user.php index b38fbb5e26..187a9b6b05 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -559,6 +559,10 @@ class WP_User_Query { $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] ); $this->results = $r; + } elseif ( 'all' == $qv['fields'] ) { + foreach ( $this->results as $key => $user ) { + $this->results[ $key ] = new WP_User( $user ); + } } }