I am working with redux framework and need to save theme option values to a file right before it is saved in DB.
Is there a way to intercept
update_option()
right before it saves data in DB?
3 Answers
You might be better off using the update_option_
action instead. This will allow you to write to your file after the option has been updated (as apposed to before). If another plugin hooks into pre_update_option_ and alters the value after your plugin has saved it then you will have saved an incorrect value.
I would use:
add_action( 'update_option_myoption', function( $old_value, $new_value ) {
//Do something with the new value
}, 10, 2);