Home › Forums › Feature Requests › Button to Reset to Default Values › Reply To: Button to Reset to Default Values
This function needs to be put into the JavaScript file that you’re enqueuing
function my_options_reset_defaults() {
if (!confirm('Are you sure you want to reset the default options?\nThis operation cannot be undone.')) {
return;
}
jQuery.post(
// the object name needs to be the same
// as the object name used when
// localizing the script
my_options_object._ajax_url, {
// the action needs to be the same
// as the wp_ajax_ action you set up
'action': 'my_options_reset',
'nonce': my_options_object._nonce
},
function (data) {
// does not matter what's returned
// reloads the options page to show defaults
location.reload();
}
);
}
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.