I am trying to get all users that meta value is empty

so i tried many variations and cant get the list of all user that birthday field is empty (not set).

        $user_query->query_vars['meta_key']     = 'birthday';
        $user_query->query_vars['meta_value']   = '';
        $user_query->query_vars['meta_value']   = Null;
        $user_query->query_vars['meta_compare'] = '='; 
  • First, as a general observation, take notice that you are altering all of the queries so make sure you are altering only the one(s) that you need. Second, do the posts actually have that birthday meta_key with an empty meta_value in the wp_postmeta table? Or you want to fetch only those IDs that don't have that meta_key / meta_value at all set in the wp_postmeta table?
    – webtoure
    Commented Jul 5, 2015 at 14:01

1 Answer 1


I think the use of meta_query is in order:

$user_query = new WP_User_Query( 
        'meta_query'=> array( 
                 'key'=> 'birthday', 
                 'compare' => 'NOT EXISTS' 

Basically, this looks for all users where the meta key of birthday doesn't have a value ie doesn't exist. More info about meta queries in WP_User_Query can be found here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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