Add jetpack_account_protection_send_auth_email filter for custom verification email handling #47999#48003
Conversation
|
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 🤖 |
|
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! |
e418072 to
cc57ebb
Compare
… 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
b215621 to
6e3ffa6
Compare
ArSn
left a comment
There was a problem hiding this comment.
Thank you for this, it looks good and I have also tested it to verify we still receive the auth code via our servers by default.
The failing tests seem unrelated to these changes, I am working on figuring that out, and will merge this once I do.
|
@ArSn also kindly assign this to me. |
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.