Make WordPress Core

Changeset 45712


Ignore:
Timestamp:
08/01/2019 03:29:02 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Users: Use get_password_reset_key() in wp_new_user_notification().

Props mrasharirfan, spacedmonkey.
Fixes #45745.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r45611 r45712  
    18941894     * @since 4.6.0 The `$notify` parameter accepts 'user' for sending notification only to the user created.
    18951895     *
    1896      * @global wpdb         $wpdb      WordPress database object for queries.
    1897      * @global PasswordHash $wp_hasher Portable PHP password hashing framework instance.
    1898      *
    18991896     * @param int    $user_id    User ID.
    19001897     * @param null   $deprecated Not used (argument deprecated).
     
    19121909        }
    19131910
    1914         global $wpdb, $wp_hasher;
    19151911        $user = get_userdata( $user_id );
    19161912
     
    19721968        }
    19731969
    1974         // Generate something random for a password reset key.
    1975         $key = wp_generate_password( 20, false );
    1976 
    1977         /** This action is documented in wp-login.php */
    1978         do_action( 'retrieve_password_key', $user->user_login, $key );
    1979 
    1980         // Now insert the key, hashed, into the DB.
    1981         if ( empty( $wp_hasher ) ) {
    1982             require_once ABSPATH . WPINC . '/class-phpass.php';
    1983             $wp_hasher = new PasswordHash( 8, true );
    1984         }
    1985         $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
    1986         $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
     1970        $key = get_password_reset_key( $user );
     1971        if ( is_wp_error( $key ) ) {
     1972            return;
     1973        }
    19871974
    19881975        $switched_locale = switch_to_locale( get_user_locale( $user ) );
Note: See TracChangeset for help on using the changeset viewer.