[wp-trac] [WordPress Trac] #38851: WP_User_Query cannot retrieve multisite users who have not been assigned a role on a site

WordPress Trac noreply at wordpress.org
Tue Jun 6 13:54:27 UTC 2017


#38851: WP_User_Query cannot retrieve multisite users who have not been assigned a
role on a site
------------------------------------------+-----------------------------
 Reporter:  robdxw                        |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  Users                         |     Version:
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+-----------------------------

Comment (by tomdxw):

 It's actually possible to retrieve all users on multisite:
 `get_users(['blog_id' => 0]);`

 This is counterintuitive because in most of WordPress, `-1` is used to
 indicate "all" and `0` is used to indicate "use the current site or user".
 And this feature appears to be undocumented.
 [https://developer.wordpress.org/reference/classes/wp_user_query/prepare_query/
 The documentation] just says "(int) The site ID. Default is the current
 site."

 I'm not going to mark this bug as fixed. I think this feature should be
 documented, and `'blog_id' => -1` should work too, for consistency.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38851#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list