[wp-trac] [WordPress Trac] #17582: Problems with duplicated users
WordPress Trac
wp-trac at lists.automattic.com
Fri May 27 03:05:46 UTC 2011
#17582: Problems with duplicated users
--------------------------+-----------------------------
Reporter: scribu | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Keywords:
--------------------------+-----------------------------
Since WP 3.2, you can do this:
{{{
$users = get_users( array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'foo',
),
array(
'key' => 'bar',
),
)
) );
}}}
which is great, except you can end up with a lot of duplicate users.
There's no straightforward way to tell WP_User_Query to add a distinct
clause.
Sure, you can do this:
{{{
add_action( 'pre_user_query', function( $user_query ) {
$user_query->query_fields = 'DISTINCT ' . $user_query->query_fields;
} );
}}}
but the query that populates {{{$user_query->total_users}}} will ignore
that.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17582>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list