Home › Forums › General Issues › How to return all user are selected field › Reply To: How to return all user are selected field
Hi @shepxbfr
You would need to use the WP_User_Query
If you check the ACF docs on checkboxes, you can see how to query them here
So something like:
<?php
$args = array(
'role' => 'subscriber',
'meta_query' => array(
array(
'key' => 'game',
'value' => '"A"',
'compare' => 'LIKE'
)
)
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->get_results() ) ) {
foreach ( $user_query->get_results() as $user ) {
echo '<p>' . $user->display_name . '</p>';
}
} else {
echo 'No users found.';
}
?>
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.