Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I wanted to update custom blog option created thru Settings Api using the function update_blog_option. I created this code.

    $country_base = get_blog_option($blog_id, 'mytheme_options');//retrieve all options
    $country_base['country_base'] = $the_country;
    $currency_unit = get_blog_option($blog_id, 'mytheme_options');//retrieve all options
    $currency_unit['currency_unit'] = $d_currency;

    update_blog_option($blog_id, 'mytheme_options', $country_base);
    update_blog_option($blog_id, 'mytheme_options', $currency_unit);

However, its not working.. Is there way to update custom blog option?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

As per the Codex on update_blog_option:

Switches to the blog id specified, runs update_option() and then restores to the current blog. If $refresh is true then it will refresh the blog details.


Not tested, but I think your problem is trying to update elements of the array instead of the whole thing:

$the_options = get_blog_option($blog_id, 'mytheme_options');//retrieve all options

$the_options['country_base'] = $the_country;
$the_options['currency_unit'] = $d_currency;

update_blog_option($blog_id, 'mytheme_options', $the_options);
share|improve this answer

I think it's best just to switch_to_blog($id); and use regular functions as add_option(), get_option(), update_option(). When you're done you'd better use restore_current_blog(); to switch back.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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