update_site_option()
Updates or adds the specified option for the current site (current blog network). For multisite networks.
If the function is used outside of a Multisite build, control is passed to the function update_option() with the parameter $autoload = 'no'.
The function is similar to update_option() or update_blog_option(), except it saves data in the main site's metadata table wp_sitemeta, rather than in the wp_options table of the current blog (site).
To retrieve such an option, you need to use the function get_site_option().
To learn about the differences between site and blog options, read the section: Structure of Sites and Blogs.
No Hooks.
Returns
true|false. True - the option was updated. False - failed to update the option.
Usage
update_site_option( $option, $value );
- $option(string) (required)
- The name of the option to update/add.
- $value(mixed) (required)
The new value of the option that will replace the previous value or be added if the specified option does not exist yet.
If the option value is passed as an array or object, it will be serialized before saving.
Notes
- Since version 4.4.0, it became a wrapper for the function update_network_option().
Examples
#1 Save the network of sites option and get it
update_site_option( 'my_site_option', 321 ); echo get_site_option( 'my_site_option' ); //> 321
Notes
Changelog
| Since 2.8.0 | Introduced. |
| Since 4.4.0 | Modified into wrapper for update_network_option() |
update_site_option() update site option code WP 7.0
function update_site_option( $option, $value ) {
return update_network_option( null, $option, $value );
}