I'm at a loss, trying to use what seemed like a rather textbook meta_query parameter as one of the arguments in a get_users() request.
I formatted the code (displayed below) using the instructions provided on the get_users Codex page, as well as the WP_Meta_Query Codex page referenced.
There is also a post on StackOverflow that suggests this same syntax should work just fine.
However it's not working for me. I am able to get results using the 'LIKE' compare key but that one can't process an array of values like 'IN' is supposed to. I could try to hack my way around this with an ugly foreach loop but I'd really rather keep it kosher.
Here's my code:
$user_query_args = array(
'role' => '',
'meta_query' => array(
array(
'key' => 'guest_type',
'value' => $gest_type // this works fine
),
array(
'key' => 'wp_'. $blog_ID .'_registration_status',
'value' => $registration_status // this works fine
),
array(
'key' => 'mandatory_tracks',
'value' => 'newphy',
'compare' => 'IN' //*** but this don't work ***
)
),
'orderby' => 'login',
'fields' => 'ID'
);
$reported_users_IDs = get_users( $user_query_args );
And just so you know I'm not crazy, this row exists in the user_meta table of the database:
82 3 mandatory_tracks a:2:{i:0;s:6:"newphy";i:1;s:9:"workforce";}
Finally, you can see my work in progress with some var_dumps here.
Any help is greatly appreciated!