[wp-trac] [WordPress Trac] #53177: WP_User_Query does not accept fields as string except ID

WordPress Trac noreply at wordpress.org
Sun May 1 00:03:37 UTC 2022


#53177: WP_User_Query does not accept fields as string except ID
-------------------------------------------------+-------------------------
 Reporter:  rilwis                               |       Owner:  audrasjb
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.0
Component:  Users                                |     Version:  4.4
 Severity:  normal                               |  Resolution:
 Keywords:  has-testing-info has-dev-note has-   |     Focuses:  docs
  patch has-unit-tests needs-docs                |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * keywords:  has-testing-info has-dev-note has-patch has-unit-tests => has-
     testing-info has-dev-note has-patch has-unit-tests needs-docs


Comment:

 The [https://developer.wordpress.org/reference/classes/wp_user_query
 /#return-fields-parameter WP_User_Query return fields documentation] will
 need an update as this changes the results a little.

 > An array of IDs, stdClass objects, or WP_User objects, depending on the
 value of the ‘fields‘ parameter.
 >
 > * If ‘fields‘ is set to ‘all’ (default), or ‘all_with_meta’, it will
 return an array of WP_User objects (does not include related user meta
 fields even with ‘all_with_meta’ set) .
 > * If ‘fields‘ is set to an array of wp_users table fields, it will
 return an array of stdClass objects with only those fields.
 > * If ‘fields‘ is set to any individual wp_users table field, an array of
 IDs will be returned.

 The last case has changed so that if a single field is set then an array
 of the single filed will be returned:

 {{{
 // specifying user name, new behavior
 array(1) {
     [0] =>
     string(5) "admin"
   }

 // specifying user name, old behavior
   array(1) {
     [0] =>
     string(1) "1"
   }

 }}}

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


More information about the wp-trac mailing list