update_blog_status() WordPress Function

This function is used to update the status of a blog post. The first parameter is the post ID, and the second parameter is the new status. The new status can be 'draft', 'pending', 'publish', or 'trash'.

update_blog_status( int $blog_id, string $pref, string $value, null $deprecated = null ) #

Update a blog details field.


Parameters

$blog_id

(int)(Required)Blog ID.

$pref

(string)(Required)Field name.

$value

(string)(Required)Field value.

$deprecated

(null)(Optional)Not used.

Default value: null


Top ↑

Return

(string|false) $value


Top ↑

Source

File: wp-includes/ms-blogs.php

function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
	global $wpdb;

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

	$allowed_field_names = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' );

	if ( ! in_array( $pref, $allowed_field_names, true ) ) {
		return $value;
	}

	$result = wp_update_site(
		$blog_id,
		array(
			$pref => $value,
		)
	);

	if ( is_wp_error( $result ) ) {
		return false;
	}

	return $value;
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)MU (3.0.0)
5.1.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.