Meta_query on same meta key, with diffrenct values

Question

i’m trying to get_users with the meta_query where i need to find users where either they don’t have the meta key, or it is blank.

It seems like everywhere i look, i should be able to use the OR on the relation and then use the same meta key, but how ever i set it up, it does not work.

My code:

$ors[] = array(
   'key'   => 'death_date',
   'compare' => '=',
   'value' => '',
   'type' => 'NUMERIC'                    
);
$ors[] = array(
   'key'   => 'death_date',
   'compare' => 'NOT EXISTS'                    
);

$args = array(
   'meta_query' => array(
   'relation' => 'or',
   $ors,
));

$return = get_users($args);

Both of them work separately, but not together.

0
, , , bymem 3 years 2019-12-06T09:13:10-05:00 0 Answers 88 views 0

Leave an answer

Browse
Browse