Home › Forums › General Issues › Using get_field to set a variable with values from a user › Reply To: Using get_field to set a variable with values from a user
So then you’ll need to query the ‘wglocations’ to get all the posts for the user and then loop through those to build a list of all the numbers to look for
$args = array(
'post_type' => 'wglocations',
'post_per_page' => -1,
'author' => $user_id
);
$query = new WP_Query($args);
$ring_numbers = array();
foreach ($query->posts as $post) {
$value = get_field('leg_ring_number', $post_id);
$values = str_replace(' ', '', $ring_numbers);
$ring_numbers = array_merge($ring_numbers, explode(',', $value));
}
Then you do the second query from the previous code
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.