Home › Forums › Front-end Issues › I can’t get userdata to show properly from a User Object select field › Reply To: I can’t get userdata to show properly from a User Object select field
When changing the ACF for this user object to return the user array, I get all the data for this “manager’. But I can’t parse out just the display_name. I’ve tried this code with no luck
$args = array('orderby' => 'display_name',);
$users = get_users($args);
foreach($users as $user){
$userID = 'user_'.$user->ID ;
echo '<li>';
echo '<b style="font-size:14px;">' . $user->data->display_name . ' x' . $user->emp_office_ext . '</b><br/>';
echo '<em style="font-size:12px;white-space: nowrap; ">' . get_field('position',$userID) . '</em>';
if (!empty(the_field('manager',$userID))){
$manager = get_field('manager',$userID);
echo $manager->display_name;
}
echo '</li>';
}
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.