why only 2 values getting updated instead of all 4
-
I have a strange problem with update_options, and with add_options.
the original stackQ :
https://wordpress.stackexchange.com/questions/134312/why-only-2-values-getting-updated-instead-of-all-4-update-optionI have a 4 var array, and try to update_option and get 2 var that is getting updated insted of 4. The script is running on admin_init.
$new_settings = array( 'Candle' => $options['Candle'], 'Havdala' => $options['Havdala'], 'updatestatus' => $updatestatus, 'lastUpdate' => $nextUpdate, ); update_option('wp_shabbat_settings', $new_settings);
When the plugin is created I register the function:
// create default values when user activate plugin function wp_shabbat_activate() { delete_option('wp_shabbat_settings'); $settings = array( 'CandleDefault' => 20, 'HavdalaDefault' => 18, 'Candle' => 20, 'Havdala' => 18, 'updatestatus' => 'Plugin DataBase need to be updated', 'lastUpdate' => 0, ); add_option('wp_shabbat_settings', $settings); include( plugin_dir_path( __FILE__ ) . 'wp-shabbat-update.php'); } register_activation_hook( __FILE__, 'wp_shabbat_activate' );
If I change the first two values the db getting updated , but last 2 aren’t changing.
I tried this also and got the same result.
$new_settings = array( 'Candle' =>55, 'Havdala' => 55, 'updatestatus' => 55, 'lastUpdate' =>55, ); print_r($new_settings); update_option('wp_shabbat_settings', $new_settings); print_r(get_option('wp_shabbat_settings'));
result of print_r:
Array ( [Candle] => 55 [Havdala] => 55 [updatestatus] => 55 [lastUpdate] => 55
result print_r(get_option(‘wp_shabbat_settings’)):
Array ( [Candle] => 55 [Havdala] => 55 [updatestatus] => file extracted succefully [lastUpdate] => 1391212800
more details:
if i delete the db delete_option(‘wp_shabbat_settings’); and then insert the 6 vlues to db add_option(‘wp_shabbat_settings’, $new_settings); , I get only 2 inside.
$new_settings = array( 'CandleDefault' => 20, 'HavdalaDefault' => 18, 'Candle' => 20, 'Havdala' => 18, 'updatestatus' => 'Plugin DataBase need to be updated', 'lastUpdate' => 0, ); print_r($new_settings); delete_option('wp_shabbat_settings'); add_option('wp_shabbat_settings', $new_settings); print_r(get_option('wp_shabbat_settings'));
result print_r($new_settings);:
Array ( [CandleDefault] => 20 [HavdalaDefault] => 18 [Candle] => 20 [Havdala] => 18 [updatestatus] => Plugin DataBase need to be updated [lastUpdate] => 0 )
result print_r(get_option(‘wp_shabbat_settings’)); :
Array ( [Havdala] => 18 [Candle] => 20 )
pls if u can help, the whole project is here :
https://github.com/drmosko/wp-shabbat
- The topic ‘why only 2 values getting updated instead of all 4’ is closed to new replies.