Make WordPress Core


Ignore:
Timestamp:
08/01/2019 11:27:28 AM (5 years 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-admin/includes/ms.php

    r45674 r45708  
    302302    </tr>
    303303    <?php
    304 }
    305 
    306 /**
    307  * Update the status of a user in the database.
    308  *
    309  * Used in core to mark a user as spam or "ham" (not spam) in Multisite.
    310  *
    311  * @since 3.0.0
    312  *
    313  * @global wpdb $wpdb WordPress database abstraction object.
    314  *
    315  * @param int    $id         The user ID.
    316  * @param string $pref       The column in the wp_users table to update the user's status
    317  *                           in (presumably user_status, spam, or deleted).
    318  * @param int    $value      The new status for the user.
    319  * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
    320  * @return int   The initially passed $value.
    321  */
    322 function update_user_status( $id, $pref, $value, $deprecated = null ) {
    323     global $wpdb;
    324 
    325     if ( null !== $deprecated ) {
    326         _deprecated_argument( __FUNCTION__, '3.0.2' );
    327     }
    328 
    329     $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
    330 
    331     $user = new WP_User( $id );
    332     clean_user_cache( $user );
    333 
    334     if ( $pref == 'spam' ) {
    335         if ( $value == 1 ) {
    336             /**
    337              * Fires after the user is marked as a SPAM user.
    338              *
    339              * @since 3.0.0
    340              *
    341              * @param int $id ID of the user marked as SPAM.
    342              */
    343             do_action( 'make_spam_user', $id );
    344         } else {
    345             /**
    346              * Fires after the user is marked as a HAM user. Opposite of SPAM.
    347              *
    348              * @since 3.0.0
    349              *
    350              * @param int $id ID of the user marked as HAM.
    351              */
    352             do_action( 'make_ham_user', $id );
    353         }
    354     }
    355 
    356     return $value;
    357304}
    358305
Note: See TracChangeset for help on using the changeset viewer.