#31878 closed defect (bug) (fixed)
get_users() on multisite returns empty user roles when other blog_id provided
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.2 | Priority: | normal |
| Severity: | normal | Version: | 3.5 |
| Component: | Users | Keywords: | |
| Focuses: | multisite | Cc: |
Description
For example if you'll query:
get_users( array( 'blog_id' => 2 ) );
This will return:
[0] => WP_User Object
(
[data] => stdClass Object
(
[ID] => XX
[user_login] => XXX
[user_pass] => XXX
[user_nicename] => XXX
[user_email] => XXX
[user_url] =>
[user_registered] => XXX
[user_activation_key] =>
[user_status] => 0
[display_name] => XXX
[spam] => 0
[deleted] => 0
)
[ID] => XX
[caps] => Array
(
)
[cap_key] => wp_capabilities
[roles] => Array
(
)
[allcaps] => Array
(
)
[filter] =>
)
Even if user got role specified for the blog with ID 2.
Change History (4)
Note: See
TracTickets for help on using
tickets.
Thanks for the report.
I've confirmed the issue. The problem is not that
'roles'is *empty* per se, it's that roles/caps are being populated from the wrong site in some cases (and in your situation, the user doesn't have any role at all on the current site). In [15566],WP_User_Querywas modified to ensure that caps are fetched from the proper 'blog_id'; in [22248],WP_User_Querywas modified to returnWP_Userobjects when 'fields=all', but the blog_id fix from [15566] was not included in the latter changeset.