Home › Forums › General Issues › User field type › Reply To: User field type
Jeremy was on the right track for the simplest solution, but had a couple typos.
FIXED code to get user ID:
$select_staff = get_sub_field('select_staff');
$select_staff_id = $select_staff['ID'];
The User Relation field returns an array of data. Using get_sub_field* instead of the_sub_field* stores that array into the variable $select_staff.
Then in order to retrieve the user ID, query the $select_staff array. Note the use of brackets for the array rather than the previous typo with parentheses.
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.