WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/01/2019 11:27:28 AM (4 months ago)
Author:
SergeyBiryukov
Message:

Users: Deprecate update_user_status() in favor of wp_update_user().

Props spacedmonkey, SergeyBiryukov.
Fixes #45747.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-deprecated.php

    r44469 r45708  
    686686    $wpdb->suppress_errors( $suppress );
    687687}
     688
     689/**
     690 * Update the status of a user in the database.
     691 *
     692 * Previously used in core to mark a user as spam or "ham" (not spam) in Multisite.
     693 *
     694 * @since 3.0.0
     695 * @deprecated 5.3.0 Use wp_update_user()
     696 * @see wp_update_user()
     697 *
     698 * @global wpdb $wpdb WordPress database abstraction object.
     699 *
     700 * @param int    $id         The user ID.
     701 * @param string $pref       The column in the wp_users table to update the user's status
     702 *                           in (presumably user_status, spam, or deleted).
     703 * @param int    $value      The new status for the user.
     704 * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
     705 * @return int   The initially passed $value.
     706 */
     707function update_user_status( $id, $pref, $value, $deprecated = null ) {
     708    global $wpdb;
     709
     710    _deprecated_function( __FUNCTION__, '5.3.0', 'wp_update_user()' );
     711
     712    if ( null !== $deprecated ) {
     713        _deprecated_argument( __FUNCTION__, '3.0.2' );
     714    }
     715
     716    $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
     717
     718    $user = new WP_User( $id );
     719    clean_user_cache( $user );
     720
     721    if ( $pref == 'spam' ) {
     722        if ( $value == 1 ) {
     723            /** This filter is documented in wp-includes/user.php */
     724            do_action( 'make_spam_user', $id );
     725        } else {
     726            /** This filter is documented in wp-includes/user.php */
     727            do_action( 'make_ham_user', $id );
     728        }
     729    }
     730
     731    return $value;
     732}
Note: See TracChangeset for help on using the changeset viewer.