Reputation: 67
I am trying to query WP users with meta_key and have one or more meta_value within an array. This array is generated from new WP_Query. I'm querying post using $args to get post IDs.
print_r ($query->posts) shows the correct array: Array ( [0] => 100 [1] => 101 [2] => 102 [3] => 103 )
Now I'm trying to get users using this array as meta_value. I have a user with my_key and 102 and 103 saved as user meta. print_r ($my_key) shows the correct user meta array: Array ( [0] => 102 [1] => 103 )
$user_args = array(
'meta_query' => array(
array(
'key' => 'my_key',
'value' => $query->posts,
'type' => 'numeric',
'compare' => 'IN'
)
),
);
$users = get_users( $user_args );
But no users are being queried... can anyone suggest what I am doing wrong?
Upvotes: 0
Views: 1203
Reputation: 413
https://codex.wordpress.org/Class_Reference/WP_User_Query
And scroll down to "Custom Field Parameters"
i guess that helps
Upvotes: 0