i have wordpress plugin register settings like:
register_settings("myplugin_settings","myplugin_option1");
and on plugin activation it's adding options like:
add_option("myplugin_option1","");
then if update option, like:
update_option("myplugin_option1","something else");
and later try database:
$myoption = get_option("myplugin_option1");
get_option() returns false, option exist , value updated.
i know value updated , option exist because when run query option getting value:
global $wpdb; $query = 'select * wp_options option_name = "myplugin_option1"; $result = $wpdb->get_results($query);
this returns me value: "something else"
for example code:
$option = get_option("myplugin_option1"); if(false == $option){ global $wpdb; $query = 'select * wp_options option_name = "myplugin_option1"'; $result = $wpdb->get_results($query); }
after code executed, $result contain value:
array ( [0] => stdclass object ( [option_id] => 11752 [option_name] => myplugin_option1 [option_value] => else [autoload] => yes ) )
so option exist , has value get_option() returning false.
i have problem 3 options , on 1 site plugin installed. has idea why get_option() returns false option in database , has value "something else".
the issue 3 options had problems somehow cached twice in wp cache.
so 1 options cached twice, , update_options() updating 1 of these 2 , get_option() getting 1 cached empty value.
not sure how happened, clearing cache resolved issue.