mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Return WP_User objects when querying 'all' fields with WP_User_Query.
Allow passing stdClass or WP_User to the WP_User constructor. fixes #22057 git-svn-id: http://core.svn.wordpress.org/trunk@22248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
74cea87b2c
commit
f9ddde8da6
@ -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;
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user