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!
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.