Hook to add_action(‘updated_option_my_option’, [$this, ‘save_data’], 10, 3]);


i want to modify my options data after save. Therefore i want to hook into “updated_option”. This works without problem.

I create a new option called “my_update_option” and want also hook into “updated_option_my_update_option” but this won’t work.

Did anyone know whats wrong in my code below?

class MyClass {

public function __construct()
    add_action('admin_init', [$this, 'theme_init']);
    add_action('admin_menu', [$this, 'theme_menu']);

    add_action('updated_option', [$this, 'save_options'], 10, 3);
    add_action('updated_option_my_update_option', [$this, 'save_my_update_option'], 10, 3);

public function theme_init()
    register_setting('my_update_option', 'theme_options', 'lapocus_validate_options', 'checkOption');

public function theme_menu()
    add_menu_page('Main Page', 'Main Page', 'my_update_option', 'menu-slug', [$this, 'main_page'], 'dashicons-admin-network', 2);
    add_submenu_page('menu-slug', 'Sub Page', 'Sub Page','my_update_option', 'menu-slug' . '-subpage-online-form', [$this, 'subpage_online_form']);

public function save_my_update_option($oldvalue, $value, $option) {
   // do something

pennylane 10 months 2022-04-11T23:52:05-05:00 0 Answers 0 views 0

Leave an answer