The WordPress core password reset needs to pre-populate the username to meet WCAG 2.2#8122
The WordPress core password reset needs to pre-populate the username to meet WCAG 2.2#8122rinkalpagdar wants to merge 9 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @pratik-londhe4. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
I've tested the above patch locally, and it seems to be working as expected. The username is pre-populated when the user resets their password and navigates to the login page afterward. |
|
Please see my note on the original PR implimenting this change, it duplicates the issues discussed there. |
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Reuses an existing parameter, preventing potential interference with extensions.
|
I've updated the PR to address feedback by @westonruter and @peterwilsoncc; could use a review. |
| } | ||
|
|
||
| if ( isset( $_GET['user_login'] ) ) { | ||
| setcookie( 'wp_user_login', sanitize_text_field( $_GET['user_login'] ), 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true ); |
There was a problem hiding this comment.
While it's unlikely that a username will have a character which will get slashed, this seems like a best practice:
| setcookie( 'wp_user_login', sanitize_text_field( $_GET['user_login'] ), 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true ); | |
| setcookie( 'wp_user_login', sanitize_text_field( wp_unslash( $_GET['user_login'] ) ), 0, COOKIEPATH, COOKIE_DOMAIN, $secure, true ); |
There was a problem hiding this comment.
Is there another more specific function used for sanitizing usernames than sanitize_text_field()?
Trac ticket: https://core.trac.wordpress.org/ticket/60726
This PR prepopulate the username into the login form after the password reset using the existing query parameter.