Add jetpack_account_protection_send_auth_email filter for custom verification email handling #47999#48003
Open
yaswanthkumar1995 wants to merge 1 commit intoAutomattic:trunkfrom
Conversation
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 |
Contributor
Author
|
Hi @nandotess — I've implemented the proposed solution and opened a PR: What's included
Could someone from the team assign this and review when you get a chance? Thanks! |
… email handling Add a filter in Email_Service::api_send_auth_email() that fires before the WPCOM API call, allowing sites to handle the verification email locally (e.g. via wp_mail()). When the filter returns truthy, the API call is skipped. Default behavior is unchanged. Fixes Automattic#47999
e418072 to
cc57ebb
Compare
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.
Fixes #47999
Summary
Adds a
jetpack_account_protection_send_auth_emailfilter inEmail_Service::api_send_auth_email()that allows sites to handle the Account Protection verification email locally instead of via the WPCOM API.Problem
The password-detection verification email is sent entirely through the WPCOM API, bypassing
wp_mail(). Sites using custom email branding (e.g. wrapping all outgoing emails in branded HTML templates) cannot intercept or customize this email, creating brand inconsistency.Solution
A new
jetpack_account_protection_send_auth_emailfilter fires before the WPCOM API call:$handledboolfalse.$user_idint$auth_codestring$blog_idint|falseWhen the filter returns truthy, the WPCOM API call is skipped — the site is responsible for delivering the email. When no filter is attached, behavior is unchanged.
Changelog
jetpack-account-protection: Minor — Addedjetpack_account_protection_send_auth_emailfilterTesting instructions:
Verify default behavior is unchanged (no filter attached):
Verify the filter short-circuits the API call:
functions.php:wp_mail()(with any site branding applied) instead of the Jetpack-branded WPCOM emailVerify filter returning false continues normal flow:
return false;Run unit tests:
cd projects/packages/account-protection composer phpunitDoes this pull request change what data or activity we track or use?
No. This PR does not change any data tracking or collection. It only adds a filter hook that allows sites to optionally handle the verification email delivery locally. When no filter is attached, the existing WPCOM API behavior is completely unchanged. No new data is sent, stored, or exposed.