Support

Account

Home Forums General Issues update ACF field for user Reply To: update ACF field for user

  • Thanks for getting back to me!I’ve worked with lots of different CRM systems, including projects where we’ve been a Salesforce implementation partner, so I’d like to share some more info about working with ACF fields for users.

    When you update a custom ACF field, there are two ways to do it: use field_name or field_key.Field_name only works if the field already exists and has a value.For example:
    update_field('location', $_POST['current_country'], 'user_'.$user_id);

    Field_key is a more reliable way, especially if the field may not exist or doesn’t have a value.For example:
    update_field('field_5fb3785065726', $_POST['current_country'], 'user_'.$user_id);

    This will help avoid problems with updating fields that may not exist.I hope this will be useful to other developers!