WordPress.org

Make WordPress Core

Ticket #18934: 18934.diff

File 18934.diff, 1.7 KB (added by PeteMall, 4 years ago)
  • wp-admin/user-edit.php

     
    118118                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) ); 
    119119 
    120120        // WPMU must delete the user from the current blog if WP added him after editing. 
    121         $delete_role = false; 
    122         $blog_prefix = $wpdb->get_blog_prefix(); 
    123121        if ( $user_id != $current_user->ID ) { 
    124                 $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:{}'" ); 
    125                 if ( !is_network_admin() && null == $cap && $_POST[ 'role' ] == '' ) { 
     122                $cap = get_user_meta( $user_id, $wpdb->prefix . 'capabilities', true ); 
     123                if ( !is_network_admin() && empty( $cap ) && empty( $_POST['role'] ) ) { 
    126124                        $_POST[ 'role' ] = 'contributor'; 
    127                         $delete_role = true; 
     125                        delete_user_meta( $user_id, $wpdb->prefix . 'capabilities' ); 
    128126                } 
    129127        } 
    130128        if ( !isset( $errors ) || ( isset( $errors ) && is_object( $errors ) && false == $errors->get_error_codes() ) ) 
    131                 $errors = edit_user($user_id); 
    132         if ( $delete_role ) // stops users being added to current blog when they are edited 
    133                 delete_user_meta( $user_id, $blog_prefix . 'capabilities' ); 
     129                $errors = edit_user( $user_id ); 
    134130 
    135131        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 ) ) 
    136132                empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );