wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



update_user_status › WordPress Function

Depuis3.0.0
Dépréciée5.3.0
update_user_status ( $id, $pref, $value, $deprecated = null )
Paramètres: (4)
  • (int) $id The user ID.
    Requis: Oui
  • (string) $pref The column in the wp_users table to update the user's status in (presumably user_status, spam, or deleted).
    Requis: Oui
  • (int) $value The new status for the user.
    Requis: Oui
  • (null) $deprecated Deprecated as of 3.0.2 and should not be used.
    Requis: Non
    Défaut: null
Voir:
Retourne:
  • (int) The initially passed $value.
Défini(e) dans:
Codex:

Update the status of a user in the database.

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


Source

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;
}