Home › Forums › Backend Issues (wp-admin) › Auto-restore default field values? › Reply To: Auto-restore default field values?
There is no setting to restore the default value. I think you have 2 options.
If you want the editor to see that it’s being restored to the default value, that would take writing some javascript to include with your field group. Probably the more difficult of the 2 options.
The other option is to add a filter to check the value before the database is updated, probably the easier option.
add_filter('acf/update_value/name=my_field_name', 'my_acf_update_value', 10, 3);
function my_acf_update_value($value, $post_id, $field) {
if (empty($value)) {
$value = $field['default_value'];
}
return $value;
}
for more information see the update_value doc page: http://www.advancedcustomfields.com/resources/filters/acfupdate_value/
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!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.