Ticket #45747: 45747.diff
| File 45747.diff, 5.5 KB (added by , 7 years ago) |
|---|
-
wp-admin/includes/ms.php
308 308 } 309 309 310 310 /** 311 * Update the status of a user in the database.312 *313 * Used in core to mark a user as spam or "ham" (not spam) in Multisite.314 *315 * @since 3.0.0316 *317 * @global wpdb $wpdb WordPress database abstraction object.318 *319 * @param int $id The user ID.320 * @param string $pref The column in the wp_users table to update the user's status321 * in (presumably user_status, spam, or deleted).322 * @param int $value The new status for the user.323 * @param null $deprecated Deprecated as of 3.0.2 and should not be used.324 * @return int The initially passed $value.325 */326 function update_user_status( $id, $pref, $value, $deprecated = null ) {327 global $wpdb;328 329 if ( null !== $deprecated ) {330 _deprecated_argument( __FUNCTION__, '3.0.2' );331 }332 333 $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );334 335 $user = new WP_User( $id );336 clean_user_cache( $user );337 338 if ( $pref == 'spam' ) {339 if ( $value == 1 ) {340 /**341 * Fires after the user is marked as a SPAM user.342 *343 * @since 3.0.0344 *345 * @param int $id ID of the user marked as SPAM.346 */347 do_action( 'make_spam_user', $id );348 } else {349 /**350 * Fires after the user is marked as a HAM user. Opposite of SPAM.351 *352 * @since 3.0.0353 *354 * @param int $id ID of the user marked as HAM.355 */356 do_action( 'make_ham_user', $id );357 }358 }359 360 return $value;361 }362 363 /**364 311 * Cleans the user cache for a specific user. 365 312 * 366 313 * @since 3.0.0 -
wp-admin/network/users.php
81 81 update_blog_status( $details->userblog_id, 'spam', '1' ); 82 82 } 83 83 } 84 update_user_status( $user_id, 'spam', '1' ); 84 $user_data = $user->to_array(); 85 $user_data['spam'] = '1'; 86 wp_update_user( $user_data ); 85 87 break; 86 88 87 89 case 'notspam': … … 90 92 foreach ( (array) $blogs as $details ) { 91 93 update_blog_status( $details->userblog_id, 'spam', '0' ); 92 94 } 93 94 update_user_status( $user_id, 'spam', '0' ); 95 $user = get_userdata( $user_id ); 96 $user_data = $user->to_array(); 97 $user_data['spam'] = '0'; 98 wp_update_user( $user_data ); 95 99 break; 96 100 } 97 101 } -
wp-includes/ms-deprecated.php
685 685 686 686 $wpdb->suppress_errors( $suppress ); 687 687 } 688 689 /** 690 * Update the status of a user in the database. 691 * 692 * Used in core to mark a user as spam or "ham" (not spam) in Multisite. 693 * 694 * @since 3.0.0 695 * @deprecated 5.1.0 696 * 697 * @global wpdb $wpdb WordPress database abstraction object. 698 * 699 * @param int $id The user ID. 700 * @param string $pref The column in the wp_users table to update the user's status 701 * in (presumably user_status, spam, or deleted). 702 * @param int $value The new status for the user. 703 * @param null $deprecated Deprecated as of 3.0.2 and should not be used. 704 * @return int The initially passed $value. 705 */ 706 function update_user_status( $id, $pref, $value, $deprecated = null ) { 707 global $wpdb; 708 709 710 _deprecated_function( __FUNCTION__, '5.1.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 /** 724 * Fires after the user is marked as a SPAM user. 725 * 726 * @since 3.0.0 727 * 728 * @param int $id ID of the user marked as SPAM. 729 */ 730 do_action( 'make_spam_user', $id ); 731 } else { 732 /** 733 * Fires after the user is marked as a HAM user. Opposite of SPAM. 734 * 735 * @since 3.0.0 736 * 737 * @param int $id ID of the user marked as HAM. 738 */ 739 do_action( 'make_ham_user', $id ); 740 } 741 } 742 743 return $value; 744 } 745 No newline at end of file -
wp-includes/user.php
1625 1625 } 1626 1626 $nickname = empty( $userdata['nickname'] ) ? $user_login : $userdata['nickname']; 1627 1627 1628 1629 if ( isset( $userdata['spam'] ) ) { 1630 if ( ! is_multisite() ) { 1631 return new WP_Error( 'no_spam', __( 'Sorry, spam is only supported on multisite.' ) ); 1632 } 1633 if ( $update && $userdata['spam'] != $old_user_data->spam ) { 1634 if ( $userdata['spam'] == 1 ) { 1635 /** 1636 * Fires after the user is marked as a SPAM user. 1637 * 1638 * @since 3.0.0 1639 * 1640 * @param int $id ID of the user marked as SPAM. 1641 */ 1642 do_action( 'make_spam_user', $ID ); 1643 } else { 1644 /** 1645 * Fires after the user is marked as a HAM user. Opposite of SPAM. 1646 * 1647 * @since 3.0.0 1648 * 1649 * @param int $id ID of the user marked as HAM. 1650 */ 1651 do_action( 'make_ham_user', $ID ); 1652 } 1653 1654 } 1655 } 1656 1628 1657 /** 1629 1658 * Filters a user's nickname before the user is created or updated. 1630 1659 *