Home › Forums › Backend Issues (wp-admin) › How do you access a User ACF field from a Post Query? › Reply To: How do you access a User ACF field from a Post Query?
// get the current user id and then get the company name associated with user
$user_id = get_current_user();
$company = get_field('company_name', 'user_'.$user_id);
// get a list of user IDs associated with the above company name
$args = array(
'meta_key' => 'company_name,
'meta_value ' => $company,
'fields' => 'ID'
)
$users = new WP_User_query($args);
I’m not sure how the posts you want to get relate to the list of user IDs
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.