Home Forums General Issues Querying users by custom field Reply To: Querying users by custom field

  • Hello, i think this is related to this topic. I have this code and doesn’t work.
    If i use just one category is ok but i don’t know how to use more that one. Can someone helps me please?

    $categories = array(8,9);
    $args = array(
    	'role__in' => 'subscriber',
    	'meta_query' => array(
    			'key' => 'field_648831166ce8e',
    			'value' => $categories,
    			'compare' => 'LIKE',
    	'fields' => array('user_email'),
    $subscribers = get_users($args);
    foreach ($subscribers as $subscriber) {
    	echo '<span>' . esc_html($subscriber->user_email) . '</span>';