Title: Hook function to submit_button when saving options
Last modified: November 27, 2019

---

# Hook function to submit_button when saving options

 *  Resolved [Holkan](https://wordpress.org/support/users/cubeinthebox/)
 * (@cubeinthebox)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/hook-function-to-submit_button-when-saving-options/)
 * Hi everyone!
 * I need some help here! I’m working on a plugin that is intended to save a manifest.
   json file in the root of WordPress installation. This plugin has a settings page
   in where the administrator can setup some values for the manifest.json such as
   the background color, theme color, short name, fcm sender Id, etc.
    All those
   values are saved correctly in the database as an option in the wp_options table.
   The thing is, I have another function in my plugin that has to be fired once 
   those values are successfuly saved in the database in order to generate the manifest.
   json. I thought that this could be done with some hook like added_options or 
   updated_options, but neither of those seems to work.
 * Is there another way to hook my function to the submit button so it gets fired
   once the submit button is clicked or even better is there a way to fire the function
   once the options are saved to database?
 * Any advice will be helpful!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [anant101289](https://wordpress.org/support/users/anant101289/)
 * (@anant101289)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/hook-function-to-submit_button-when-saving-options/#post-12180807)
 * Hello [@cubeinthebox](https://wordpress.org/support/users/cubeinthebox/),
 * Looking at the sources (core files, wp-includes/option.php) you can always find
   your target hook tags:
 *     ```
       add_action('added_option', 'callback_function', 10, 2);
       add_action('updated_option', 'callback_function', 10, 3);
       ```
   
 * or you can use setting api or option api for that.
 * please check below links for reference,
 * [https://developer.wordpress.org/plugins/settings/options-api/](https://developer.wordpress.org/plugins/settings/options-api/)
 * [https://developer.wordpress.org/plugins/settings/settings-api/](https://developer.wordpress.org/plugins/settings/settings-api/)
 * Thanks & Regards
    -  This reply was modified 6 years, 6 months ago by [anant101289](https://wordpress.org/support/users/anant101289/).
    -  This reply was modified 6 years, 6 months ago by [bcworkz](https://wordpress.org/support/users/bcworkz/).
      Reason: code fixed
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/hook-function-to-submit_button-when-saving-options/#post-12182611)
 * I’d use the option name specific hooks “add_option_{$option}” and “update_option_{
   $option}” so the callbacks run only when your specific option is added/updated,
   saving your callback the trouble of checking.
 * If the ‘added_option’ and ‘updated_option’ hooks aren’t working for you, something
   else is going on beyond whether you are using the right hooks or not. Perhaps
   you should share the pertinent parts of your code. If the code is sizable, please
   use pastebin.com or gist.github.com to share your code and just place the resulting
   link here.
 * If the values are saved in the DB, why repeat that in a manifest.json file? Redundant
   data should be avoided.
 * [@anant101289](https://wordpress.org/support/users/anant101289/) – thanks for
   contributing. When you provide code snippets in these forums, please demarcate
   with backticks or use the code button. Otherwise the forum’s parser corrupts 
   your code. I fixed the code in your earlier reply.
 *  [anant101289](https://wordpress.org/support/users/anant101289/)
 * (@anant101289)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/hook-function-to-submit_button-when-saving-options/#post-12185278)
 * Hello [@bcworkz](https://wordpress.org/support/users/bcworkz/),
 * Thanks for your suggestion,next time i will keep in mind.
 * Thanks
 *  [alexa0](https://wordpress.org/support/users/alexa0/)
 * (@alexa0)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/hook-function-to-submit_button-when-saving-options/#post-12543520)
 * I am using super form plugin, but when i used submit button to redirect to custom
   url the super form nerver validate the form and redirect to url even without 
   the saving the form, help me!
    -  This reply was modified 6 years, 2 months ago by [alexa0](https://wordpress.org/support/users/alexa0/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Hook function to submit_button when saving options’ is closed to new 
replies.

## Tags

 * [settings](https://wordpress.org/support/topic-tag/settings/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 4 participants
 * Last reply from: [alexa0](https://wordpress.org/support/users/alexa0/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/hook-function-to-submit_button-when-saving-options/#post-12543520)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
