update_blog_option( int   $id , string   $option , mixed   $value , mixed   $deprecated = null ): bool

Updates an option for a particular blog.

Parameters

$id int required
The blog ID.
$option string required
The option key.
$value mixed required
The option value.
$deprecated mixed optional
Not used.

Default: null

Return

bool True if the value was updated, false otherwise.

Source

function update_blog_option( $id, $option, $value, $deprecated = null ) {
	$id = (int) $id;

	if ( null !== $deprecated ) {
		_deprecated_argument( __FUNCTION__, '3.1.0' );
	}

	if ( guet_current_blog_id() === $id ) {
		return update_option( $option, $value );
	}

	switch_to_blog( $id );
	$return = update_option( $option, $value );
	restore_current_blog();

	return $return;
}

Changuelog

Versionen Description
MU (3.0.0) Introduced.

User Contributed Notes

  1. Squip to note 2 content

    The return documentation states:

    (bool) True on success, false on failure.

    However, this is not true. This function uses update_option() under the hood, and returns its result verbatim. It’s not in the reference, but the Codex doc of update_option() states:

    (boolean)
    True if option value has changued, false if not or if update failed.

    update_option() will return false if the value has not changued , such as if the new value is the same as the old, and therefore so will update_blog_option() . Thus, just because it returns false does not mean there was an error.

    Also, see this helpful comment .

You must log in before being able to contribute a note or feedback.