WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the codex it says its possible to do get_users() with multiple meta keys by using the meta_query parameter but it doesn't explain how. Can someone give me an example?

share|improve this question
up vote 5 down vote accepted

As it mentions in the Codex page for get_users, it works the same as a WP_Query meta_query, see that page for full arguments list and examples.

$args = array(
    'meta_query' => array(
            'key' => 'some_key',
            'value' => 'foo',
            'compare' => '='
            'key' => 'another_key',
            'value' => array( 'bar', 'baz' )
            'compare' => 'IN'
share|improve this answer
I'm having trouble getting this to work with the 'NOT EXISTS' operator as the value of 'compare'. If I want to return all users that DON'T have a specific key, should this work? array('key'=>'some_key','compare'=>'NOT EXISTS') – emersonthis Sep 29 '12 at 17:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.