0

I am attempting to use update_option to add or update an option.

I have created a test below which creates a settings page and when loaded it runs my awd_do_sync function, but the option does not get added or updated - why is this happening and what is the fix?

class MyClass {

    public function __construct() {

        add_action( 'admin_menu', array( $this, 'awd_settings' ) );

    }

    public function awd_settings() {

        add_submenu_page(
            'options-general.php',
            'AWD Settings',
            'AWD',
            'manage_options',
            'awd-settings',
            array( $this, 'awd_settings_page' )
        );

    }

    public function awd_settings_page() {

        $this->awd_do_sync();

    }

    public function awd_do_sync() {

        $log = 'test';

        update_option( 'awd_log', $log );

    }   

}

$go = new MyClass();

SOLVED:

I realised this was occurring because in my code, $log was a huge amount of text, therefore it appears there is a limit to what you can store in an option.

1

I realised this was occurring because in my code, $log was a huge amount of text, therefore it appears there is a limit to what you can store in an option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.