I have a call to update_option() inside a class which edits some keys from the options array passed to it and then saves the updated array to the database, I don't have any fancy code, the function is only calling the
update_option() function like this:
update_option( 'my_options', $this->updated_options );
Now this class is initialized in an admin page:
$instance = new My_Class($options_to_update); $instance->init(); // the function that updates the option is called here
The thing is that
update_option() is returning
true and updating the option with an empty value.
also I checked the array just before the call to this function and nothing is wrong:
print_r( $this->updated_options );
I also tried to update with a string:
update_option( 'my_options', 'any string' );
Now my questions are:
Am I doing something wrong ?
Is there a specific time to call
update_option()? because I have it in a function hooked to
admin_initand it's working fine.
I found out that it's not working only if i's called inside the display function of
add_menu_page() any reason why ? the passed value is always