Repository navigation
Conversation
The login notice and the user email shown after a compromised-password reset built their link from wp_login_url(), which skips the lostpassword_url filter. Sites that move their lost-password flow (WooCommerce My Account, membership sites) sent these users to the stock wp-login.php form.
|
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: @chubes4. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Builds the "create a new password" link in the compromised-password login notice and the user email from
wp_lostpassword_url(), instead ofadd_query_arg( 'action', 'lostpassword', wp_login_url() ).Related to #1039 / #1046. This is not a duplicate: #1046 lets sites replace these emails, while this makes the default link correct.
Why?
wp_lostpassword_url()is how core builds this link (it's what wp-login.php's own "Lost your password?" uses), and it runs through thelostpassword_urlfilter. WooCommerce My Account and most membership plugins hook that filter to point at their own lost-password page.Building the URL from
wp_login_url()skips that filter. On those sites, a user locked out by the failed-attempt reset is sent from the notice and from the email to the stockwp-login.php?action=lostpasswordform. That's a page those users may never have seen, and some sites disable or redirect it.With this change, sites that customize their lost-password URL get the right link with no Two Factor-specific code. Sites that don't keep the same
wp-login.php?action=lostpassworddestination. The one difference: on a site that filters onlylogin_urland notlostpassword_url, the link now goes to core's default lost-password URL. That's the same URL core itself links to.How?
Two_Factor_Core::maybe_show_reset_password_notice():esc_url( wp_lostpassword_url() ).Two_Factor_Core::notify_user_password_reset():esc_url( wp_lostpassword_url() ).lostpassword_urlfilter, and the email no longer containswp-login.phpwhen the filter is set.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code (Extra Chill Bot)
Model(s): Claude
Used for: Found this while auditing every place an Extra Chill member could land on a stock wp-login.php screen. The agent wrote the change and tests; I reviewed them.
Testing Instructions
npm run test(single site and multisite), ornpm run composer -- test -- --filter 'lost_password_url'.add_filter( 'lostpassword_url', fn() => home_url( '/my-account/lost-password/' ) );, set_two_factor_password_was_reseton a user, and try logging in with a wrong password. The notice's "create a new password" link goes to/my-account/lost-password/. The email sent byTwo_Factor_Core::notify_user_password_reset()uses the same URL.Ran in wp-env (PHP 7.4):
composer test-singleOK (363 tests, 1330 assertions),composer test-multisiteOK (363 tests), phpcs clean on the changed files.Changelog Entry