Trigger a custom function when option are saved in admin area


I am creating a WordPress theme from scratch and I would like to save a file with the theme option anytime the theme options change.

I was thinking about:

do_action('admin_init', 'my_custom_function');
function my_custom_function(){

but in this case the file will be save anytime the admin area is loaded.

On the dashboard the theme creates forms to manage the theme options, like the following:

<form method="post" action="options.php">

    <?php settings_fields( 'theme-settings-group' ); ?>
    <?php do_settings_sections( 'theme-settings-group' ); ?>

    // form in here
    <?php submit_button(); ?>


This form send information to options.php which save the theme options on the database based on the setting group specified.

I would like to trigger an function any time something is saved in “options.php”.

Can you guys suggest please?

, , , Marcello Perri 8 months 0 Answers 90 views 0

Leave an answer