Home › Forums › General Issues › Change user type field's return from array to ID, every CPT needs to be updated? › Reply To: Change user type field's return from array to ID, every CPT needs to be updated?
A user field always holds an array of user IDs. This might change if you only allow one user to be selected, but I don’t think so. You must still loop over the even when you are returning IDs.
$users = get_field('user_field_name');
// just in case it has a single value
if (!is_array('$users') && !emapty($users)) {
$users = array($users);
}
if ($users) {
foreach ($users as $user_id) {
// do something with user id
}
}
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.