[wp-trac] [WordPress Trac] #22212: WP_User_Query( array('role' => $role) ) should accept array or not return anything if array

WordPress Trac noreply at wordpress.org
Mon Mar 25 00:11:56 UTC 2013


#22212: WP_User_Query( array('role' => $role) ) should accept array or not return
anything if array
-------------------------------------------------+-------------------------
 Reporter:  thomask                              |       Owner:
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Users                                |  Review
 Severity:  normal                               |     Version:
 Keywords:  has-patch needs-unit-tests needs-    |  Resolution:
  testing                                        |
-------------------------------------------------+-------------------------
Changes (by barrykooij):

 * keywords:  has-patch => has-patch needs-unit-tests needs-testing


Comment:

 Thanks for your feedback. I've tried to setup a separate instance of
 WP_Meta_Query but this resulted in a database error because the same meta
 table was joined without an alias multiple times (WP_Meta_Query.get_sql).
 As far as I could see it's not possible to use WP_Meta_Query to do
 multiple meta queries from separate WP_Meta_Query objects on the same meta
 table.

 I did not want to change or extends the WP_Meta_Query class so I've
 extended the WP_User_Query.prepare_query function to let it create the SQL
 statements required to do a proper user fetch.

 Attached patch (user.php.2.patch) solves more then reported
 bug/enhancement, it also solves:
 - using the 'meta_query' in combination with the 'OR' relation returns all
 users (with all roles)
 - using the 'meta_query' in combination with the 'OR' relation in
 multisite returns all users (of all blogs)

 I will add Unit Tests to tomorrow.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22212#comment:14>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list