Use user_email error code for malformed email on registration and profile#11944
Conversation
…file. Reserve invalid_email for unknown or unregistered email addresses during login and password reset. Fixes inconsistent error keys reported in #60737.
|
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 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. |
WordPress currently uses the invalid_email error code for two different situations:
Login / password reset — no user exists for the given email address.
Registration / profile update — the email fails is_email() format validation.
That overlap makes it hard for plugins and themes to branch on error type without inspecting translated message strings.
This change aligns format-validation errors with the existing user_email convention (already used in multisite signup validation):
user_email — malformed email on registration (register_new_user()) and profile/user edit (edit_user()).
invalid_email — unchanged for unknown/unregistered email during login, application passwords, and password reset.
Also adds user_email to the login form shake error codes in wp-login.php so registration errors shake the form consistently.
Includes PHPUnit coverage for both registration and profile validation paths.
Backward compatibility: Code that checks invalid_email only on registration or profile update for format errors will need to handle user_email as well.
Trac ticket: https://core.trac.wordpress.org/ticket/60737
Use of AI Tools
AI assistance: Yes
Tool(s): Cursor (Auto)
Used for: Exploring the codebase and drafting this PR description. Final code was edited and reviewed by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request.