Support Forum
Support › MB Settings Page › Adding field (button) when option has changedResolved
Hi there,
I wonder if this is possible:
I have a selectbox on a settings page that lets the user select a certain API network.
When the user has selected a API to work with, I want to show a button that allows them to import data into the site. However, I don't want to use a condition-logic 'visible' parameter, but add the button at runtime.
I need it at runtime, because after the option is saved, it has to prepare some other stuff first.
I know how to add fields to the array using wp-filter-hooks.
I need a button to appear RIGHT AFTER saving the options. The problem that I'm facing however is that the options are saved only after the rwmb_meta_boxes filter has ran.
The button is thereby only shown after a reload of settings page.
Even more confusing is when you turn off using any of the API's again. After clearing the API-setting, the button is still shown, solved after a reload.
I wonder if there is a solution to this?
Hi,
It is impossible to add a new field right after saving changes. For a better experience, I recommend using MB Conditional Logic to show/hide a field base on the select option.
Thanks Long,
I already looked into the MB Conditional Logic but because the button performs an action that requires the wp_option to already be set that makes it a very confusing experience. The text on the button is "synchronize" and it fetches data from one of several different API's that runs a script to convert it into a CPT, taxonomies and terms.
Maybe you can point me to an action- hook that gets called after setting the wp_option, that I can exploit to reload the page using javascript?
Hi,
These hooks maybe help you fire an action after updated an option
update_option_{option_name}
: Fires after the value of a specific option has been successfully updated.updated_option
: Fires after the value of an option has been successfully updated.
For more information, please follow documentations
https://developer.wordpress.org/reference/hooks/updated_option/
https://developer.wordpress.org/reference/hooks/update_option_option/
https://wordpress.stackexchange.com/questions/177272/hook-if-somebody-saves-plugin-options/177280
Thank you, for some reason I had totally forgotten about those! I can work with this!