If we need to debug add, update or delete actions on the wp_options
table, we can use below hooks.
Fires before an option is added.
add_action('add_option', function( $option_name, $option_value ) {
//....
}, 10, 2);
Fires after a specific option has been added.
add_action('add_option_foo', function( $option_name, $option_value ) {
//....
}, 10, 2);
Fires after an option has been added.
add_action('added_option', function( $option_name, $option_value ) {
//....
}, 10, 2);
Fires immediately before an option value is updated.
add_action('update_option', function( $option_name, $old_value, $new_value ) {
//....
}, 10, 3);
FFires after the value of a specific option has been successfully updated.
add_action('update_option_foo', function( $option_name, $old_value, $new_value ) {
//....
}, 10, 3);
Fires after an option has been successfully updated.
add_action('updated_option', function( $option_name, $old_value, $new_value ) {
//....
}, 10, 3);
Fires immediately before an option is deleted.
add_action('delete_option', function( $option_name ) {
//....
}, 10);
Fires after a specific option has been deleted.
add_action('delete_option_foo', function( $option_name ) {
//....
}, 10);
Fires after an option has been deleted.
add_action('deleted_option', function( $option_name ) {
//....
}, 10);
If you found this article interesting, found errors, or just want to discuss about them, please get in touch.