Updating choices for a field, or any other information can be done using the
acf_update_field() function. This function is not documented, but it is the function that ACF calls internally to update a field when it’s changed in the admin.
// get the field... use the field key $field = get_field_object('field_1234567'); // modify the settings of the field $field['choices']['new-choice-value'] = 'new choice label'; // tell ACF to update the field settings acf_update_field($field);
There are other ways to accomplish some other things that might be a better field. Filters on acf/load_field https://www.advancedcustomfields.com/resources/acf-load_field/ and acf/prepare_field https://www.advancedcustomfields.com/resources/acf-prepare_field/ can be use to temporarily alter values for display.
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!
© 2022 Advanced Custom Fields.