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?
<?php
$categories = array(8,9);
$args = array(
'role__in' => 'subscriber',
'meta_query' => array(
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>';
}
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.