add_site_option() WordPress Function

The add_site_option() function is used to add a new option to the WordPress database. This function is similar to the add_option() function, but it is used for site-wide options.

add_site_option( string $option, mixed $value ) #

Adds a new option for the current network.


Description

Existing options will not be updated. Note that prior to 3.3 this wasn’t the case.

Top ↑

See also


Top ↑

Parameters

$option

(string)(Required)Name of the option to add. Expected to not be SQL-escaped.

$value

(mixed)(Required)Option value, can be anything. Expected to not be SQL-escaped.


Top ↑

Return

(bool) True if the option was added, false otherwise.


Top ↑

More Information

This function essentially the same as add_option() but works network wide when using WP Multisite.

The only major difference is that on multisite site-wide options will not autoload and on a single site the option will autoload. Unlike when using add_option() on a single site, the feature cannot be overridden.


Top ↑

Source

File: wp-includes/option.php

function add_site_option( $option, $value ) {
	return add_network_option( null, $option, $value );
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Modified into wrapper for add_network_option()
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More