I have a form which does

<form method="post" action="options.php">
.........
<input type="submit" class="button-primary" value="<?php _e( 'Save changes', 'bsp_style_settings' ); ?>" />

I have all the register settings/admin_init’s etc. and it all works fine and saves the data to WP_Options part of the database- great !

All I want to do is add an additional function that is also carried out on submit. So simple call to say

function also_do () {
xxxx
}

so this function also executes when save is pressed.

Any suggestions on how to solve this?

2 Answers
2

You could just do a check for settings updated, and call a function.

At the top of the page that renders the settings form:

if ( isset( $_GET['settings-updated'] ) && $_GET['settings_updated'] == true ) {
    your_custom_function();
}

Then define the custom function in your functions.php or add it to a class.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *