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);
    // use field key here
    update_field('field_12345abcde', $current_user);