WordPress.org

Make WordPress Core

Ticket #15627: delete-by-cap-key.diff

File delete-by-cap-key.diff, 1013 bytes (added by wonderboymusic, 3 years ago)
  • wp-includes/ms-functions.php

     
    900900 * @param string $email The new user's email address. 
    901901 * @return mixed Returns false on failure, or int $user_id on success 
    902902 */ 
    903 function wpmu_create_user( $user_name, $password, $email) { 
     903function wpmu_create_user( $user_name, $password, $email ) { 
    904904        $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); 
    905905 
    906906        $user_id = wp_create_user( $user_name, $password, $email ); 
    907         if ( is_wp_error($user_id) ) 
     907        if ( is_wp_error( $user_id ) ) 
    908908                return false; 
    909909 
     910        $user = new WP_User( $user_id ); 
     911         
    910912        // Newly created users have no roles or caps until they are added to a blog. 
    911         delete_user_option( $user_id, 'capabilities' ); 
     913        delete_user_option( $user_id, $user->cap_key ); 
    912914        delete_user_option( $user_id, 'user_level' ); 
    913915 
    914916        do_action( 'wpmu_new_user', $user_id );