Warning: This function has been deprecated. Use wp_update_user() instead.

update_user_status() WordPress Function

The update_user_status() function is used to update the status of a user in the WordPress database. This function takes two parameters: the user ID and the new status. The new status can be either "active" or "inactive".

update_user_status( int $id, string $pref, int $value, null $deprecated = null ) #

Update the status of a user in the database.


Description

Previously used in core to mark a user as spam or "ham" (not spam) in Multisite.

Top ↑

See also


Top ↑

Parameters

$id

(int)(Required)The user ID.

$pref

(string)(Required)The column in the wp_users table to update the user's status in (presumably user_status, spam, or deleted).

$value

(int)(Required)The new status for the user.

$deprecated

(null)(Optional)Deprecated as of 3.0.2 and should not be used.

Default value: null


Top ↑

Return

(int) The initially passed $value.


Top ↑

Source

File: wp-includes/ms-deprecated.php

function update_user_status( $id, $pref, $value, $deprecated = null ) {
	global $wpdb;

	_deprecated_function( __FUNCTION__, '5.3.0', 'wp_update_user()' );

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

	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );

	$user = new WP_User( $id );
	clean_user_cache( $user );

	if ( 'spam' === $pref ) {
		if ( $value == 1 ) {
			/** This filter is documented in wp-includes/user.php */
			do_action( 'make_spam_user', $id );
		} else {
			/** This filter is documented in wp-includes/user.php */
			do_action( 'make_ham_user', $id );
		}
	}

	return $value;
}


Top ↑

Changelog

Changelog
VersionDescription
5.3.0Use wp_update_user()
3.0.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.