I’m using an ACF User Field. Here is a screenshot of the field and it’s settings:

This allows me to easily pick specific users and display them on the page where I have selected them. Think of it like creating little TEAM pages.

Now in my page template I am using the following code to call all of the users’ DISPLAY NAMES that I have selected in my field for that page.
$values = get_field('choose_directory');
if($values)
{
echo '<ul>';
foreach($values as $value)
{
echo '<li>' . $value['display_name'] . '</li>';
}
echo '</ul>';
}
This all works fine… HOWEVER I also need to be able to display additional bits of information about my users. Such as phone number, job title, department. These are all additional field values that are ACF fields attached to the users profile.
Typically I would write something like:
echo '' . $user->phone_number . '';
… but that’s not working for me here in this loop.
What can I do to call these additional bits of information about each user??
Thanks so much!
Ok, so I think I might have solved it. Please let me know if this is the best way tho…
$values = get_field('choose_directory');
if($values)
{
echo '<ul>';
foreach($values as $value)
{
$user_db = $value['ID'];
echo '<li>' . $value['display_name'] . '</br>';
the_field('phone_number', 'user_'. $user_db );
echo '</li>';
}
echo '</ul>';
}
Hi @juiceex
I’m glad you solved the issue. If you use ACF to add the extra information, then your method is the best way to do it.
Thanks 🙂