0

This should b really easy but I can't find reference - easy points for someone!

I have an option in my wp_options table, and need to set it via update_option(). I just can't find the correct syntax for doing something similar to the following where I update the key object_key in the option my_plugin_settings where this is an option in my wp_options table:

update_option('my_plugin_settings[object_key]','new value');

How is it done correctly?

1

Sorry for being dense, you need to grab the object, overwrite the key you want to set and then save the updated object as the new option:

$my_plugin_settings = get_option('my_plugin_settings');
$my_plugin_settings->object_key = 'new_value';
update_option('my_plugin_settings', $my_plugin_settings);

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.