Home › Forums › General Issues › Multiple Select User Field and update_field() › Reply To: Multiple Select User Field and update_field()
When there is no value already existing for an ACF field what you need to do is use the field key instead of the field name. The field key should always be used when dealing with update_field(). The documentation here on this site show using the field name, but there is always the problem of ACF fields that have not been saved yet unable to return a value.
$current_user = get_current_user_id();
$current_user = strval($current_user); //converting to string just in case
// use field key here
$test = get_field('field_12345abcde', false, false);
$current_user = array($current_user);
print_r($test);
print_r($current_user);
// use field key here
update_field('field_12345abcde', $current_user);
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.