WordPress.org

Make WordPress Core

Ticket #24465: 24465.2.patch

File 24465.2.patch, 2.3 KB (added by jfarthing84, 6 years ago)

Refresh against trunk.

  • wp-includes/user.php

     
    23772377         */
    23782378        $user_email = apply_filters( 'user_registration_email', $user_email );
    23792379
     2380        $generated_pass = wp_generate_password( 12, false );
     2381
     2382        /**
     2383         * Filter the auto-generated password of a user being registered.
     2384         *
     2385         * @since unknown
     2386         *
     2387         * @param string $user_pass The auto-generated password of the new user.
     2388         */
     2389        $user_pass = apply_filters( 'user_registration_password', $generated_pass );
     2390
    23802391        // Check the username
    23812392        if ( $sanitized_user_login == '' ) {
    23822393                $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) );
     
    24202431         * If any errors are present in $errors, this will abort the user's registration.
    24212432         *
    24222433         * @since 2.1.0
     2434         * @since unknown Added `$user_pass` parameter.
    24232435         *
    24242436         * @param WP_Error $errors               A WP_Error object containing any errors encountered
    24252437         *                                       during registration.
    24262438         * @param string   $sanitized_user_login User's username after it has been sanitized.
    24272439         * @param string   $user_email           User's email.
     2440         * @param string   $user_pass            User's password.
    24282441         */
    2429         $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
     2442        $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email, $user_pass );
    24302443
    24312444        if ( $errors->get_error_code() )
    24322445                return $errors;
    24332446
    2434         $user_pass = wp_generate_password( 12, false );
    24352447        $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
    24362448        if ( ! $user_id || is_wp_error( $user_id ) ) {
    24372449                $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
     
    24382450                return $errors;
    24392451        }
    24402452
    2441         update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
     2453        if ( $generated_pass == $user_pass )
     2454                update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
    24422455
    24432456        wp_new_user_notification( $user_id, $user_pass );
    24442457