Make WordPress Core


Ignore:
Timestamp:
02/10/2026 07:51:56 PM (6 months ago)
Author:
joedolson
Message:

Login and Registration: Populate username after password reset.

Accessibility: to meet WCAG 2.2/3.3.7: Redundant entry, the username should be auto-populated when a user performs a password reset.

There is an existing cookie set that contains this information, but was deleted before displaying the login form.

Move cookie deletion to occur after displaying login form and use to set $user_login.

Props estelaris, alh0319, sabernhardt, oglekler, peterwilsoncc, rcreators, rishavdutta, chaion07, stoyangeorgiev, rinkalpagdar, pratiklondhe, lukasfritzedev, ferdoused, audrasjb, westonruter, joedolson.
Fixes #60726.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r61411 r61610  
    10011001                if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
    10021002                        reset_password( $user, $_POST['pass1'] );
    1003                         setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
    10041003                        login_header(
    10051004                                __( 'Password Reset' ),
     
    14881487                }
    14891488
     1489                // Obtain user from password reset cookie flow before clearing the cookie.
     1490                $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
     1491                if ( isset( $_COOKIE[ $rp_cookie ] ) && is_string( $_COOKIE[ $rp_cookie ] ) ) {
     1492                        $user_login      = sanitize_user( strtok( wp_unslash( $_COOKIE[ $rp_cookie ] ), ':' ) );
     1493                        list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
     1494                        setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
     1495                }
     1496
    14901497                login_header( __( 'Log In' ), '', $errors );
    14911498
Note: See TracChangeset for help on using the changeset viewer.