Make WordPress Core

Ticket #18934: 18934.3.diff

File 18934.3.diff, 2.6 KB (added by jeremyfelt, 7 years ago)
  • src/wp-admin/user-edit.php

     
    146146        do_action( 'edit_user_profile_update', $user_id );
    147147}
    148148
    149 if ( !is_multisite() ) {
    150         $errors = edit_user($user_id);
    151 } else {
     149// Update the email address in signups, if present.
     150if ( is_multisite() ) {
    152151        $user = get_userdata( $user_id );
    153152
    154         // Update the email address in signups, if present.
    155         if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) )
     153        if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) {
    156154                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) );
    157 
    158         // We must delete the user from the current blog if WP added them after editing.
    159         $delete_role = false;
    160         $blog_prefix = $wpdb->get_blog_prefix();
    161         if ( $user_id != $current_user->ID ) {
    162                 $cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$user_id}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
    163                 if ( !is_network_admin() && null == $cap && $_POST[ 'role' ] == '' ) {
    164                         $_POST[ 'role' ] = 'contributor';
    165                         $delete_role = true;
    166                 }
    167155        }
    168         if ( !isset( $errors ) || ( isset( $errors ) && is_object( $errors ) && false == $errors->get_error_codes() ) )
    169                 $errors = edit_user($user_id);
    170         if ( $delete_role ) // stops users being added to current blog when they are edited
    171                 delete_user_meta( $user_id, $blog_prefix . 'capabilities' );
     156}
     157
     158// Update the user.
     159$errors = edit_user( $user_id );
    172160
    173         if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
    174                 empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
     161// Grant or revoke super admin status if requested.
     162if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) {
     163        empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
    175164}
    176165
    177166if ( !is_wp_error( $errors ) ) {