Skip to content

feat(my-account): sync admin email change with external connections#3799

Merged
chickenn00dle merged 1 commit into
trunkfrom
feat/sync-email-change-on-admin-update
Mar 6, 2025
Merged

feat(my-account): sync admin email change with external connections#3799
chickenn00dle merged 1 commit into
trunkfrom
feat/sync-email-change-on-admin-update

Conversation

@chickenn00dle

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Closes https://app.asana.com/0/1208993180326452/1209589552372839

This PR triggers a sync with both Stripe and the site ESP when an email address is updated by an admin

How to test the changes in this Pull Request:

  1. Make sure the NEWSPACK_EMAIL_CHANGE_ENABLED constant is defined and true in wp-config
  2. As an admin go to Users and select a user that is associated with a Stripe account
  3. Change the email address, save, then check stripe to confirm the email address was updated
  4. Repeat step 1, but this time with a user that is associated with a contact from the sites ESP
  5. Again, change the email address, save, then check the ESP to confirm the email address was updated

Note: error cases for ESP sync are being tackled in another PR, so be sure to only update to an email address that doesn't exist in the ESP.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@chickenn00dle chickenn00dle requested a review from a team as a code owner March 5, 2025 21:36
@chickenn00dle chickenn00dle added the [Status] Needs Review The issue or pull request needs to be reviewed label Mar 5, 2025
@chickenn00dle chickenn00dle force-pushed the feat/sync-email-change-on-admin-update branch from 6442228 to a3493cc Compare March 5, 2025 21:38

@miguelpeixe miguelpeixe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described! Just a question regarding the guard clause.

Comment on lines +908 to +910
if ( ! is_admin() || ! self::is_email_change_enabled() ) {
return;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check be preventing an email update? Bailing here just means the email change happened without the required syncs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so. We bail here if the request is not from admin since non-admin requests are handled via a different hook, or if the feature is not enabled to maintain the existing behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, just realized I didn't directly answer your first question:

Should this check be preventing an email update?

No. At least we aren't doing this currently, so my assumption is this is expected.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining! I believe we could go without this clause. is_email_change_enabled() is not whether the sync should happen, it's whether we allow a reader to change their email. Non-blocking, though!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we could go without this clause. is_email_change_enabled() is not whether the sync should happen, it's whether we allow a reader to change their email. Non-blocking, though!

I think you're correct, although the goal here is to make sure the behavior remains consistent when this feature is not enabled, so we'd need this to make sure admins can still change email addresses without triggering the sync.

I'll keep it for now, but can remove if it causes issues down the line!

@github-actions github-actions Bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Mar 6, 2025
@chickenn00dle chickenn00dle merged commit 7179ffd into trunk Mar 6, 2025
@chickenn00dle chickenn00dle deleted the feat/sync-email-change-on-admin-update branch March 6, 2025 19:10
@github-actions

github-actions Bot commented Mar 6, 2025

Copy link
Copy Markdown

Hey @chickenn00dle, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Mar 6, 2025
# [6.1.0-alpha.1](v6.0.1...v6.1.0-alpha.1) (2025-03-06)

### Bug Fixes

* **modal-checkout:** password setup ([8fbfabd](8fbfabd))
* **my-account:** handle email change esp sync errors ([#3792](#3792)) ([3d9f294](3d9f294))
* **my-account:** send change email to old and new emails ([#3786](#3786)) ([710d53d](710d53d))
* **premium-newsletters:** show premium lists in post-checkout signup ([#3788](#3788)) ([ccb1526](ccb1526))
* spacer block handling with registration block ([e9b7beb](e9b7beb))

### Features

* **correction-blocks:** Correction box & Loop item + Template ([#3787](#3787)) ([c215dc2](c215dc2))
* **correction-blocks:** update corrections template ([#3793](#3793)) ([c7aea33](c7aea33))
* **my-account:** add email change cancellation option ([#3778](#3778)) ([600ad61](600ad61))
* **my-account:** sync admin email change with ESP/stripe ([#3799](#3799)) ([7179ffd](7179ffd))
* **my-account:** sync email change with esp ([#3780](#3780)) ([983c087](983c087))
* **my-account:** sync email change with stripe ([#3789](#3789)) ([4f45795](4f45795))
@matticbot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.1.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 18, 2025
# [6.1.0](v6.0.5...v6.1.0) (2025-03-18)

### Bug Fixes

* **modal-checkout:** endpoint to refresh newsletter lists via REST ([#3841](#3841)) ([2b294e0](2b294e0))
* **modal-checkout:** password setup ([8fbfabd](8fbfabd))
* **my-account:** handle email change esp sync errors ([#3792](#3792)) ([3d9f294](3d9f294))
* **my-account:** send change email to old and new emails ([#3786](#3786)) ([710d53d](710d53d))
* **premium-newsletters:** show premium lists in post-checkout signup ([#3788](#3788)) ([ccb1526](ccb1526))
* spacer block handling with registration block ([e9b7beb](e9b7beb))

### Features

* **correction-blocks:** Correction box & Loop item + Template ([#3787](#3787)) ([c215dc2](c215dc2))
* **correction-blocks:** update corrections template ([#3793](#3793)) ([c7aea33](c7aea33))
* enable email change for newspack users ([#3824](#3824)) ([9c152a8](9c152a8))
* **my-account:** add email change cancellation option ([#3778](#3778)) ([600ad61](600ad61))
* **my-account:** sync admin email change with ESP/stripe ([#3799](#3799)) ([7179ffd](7179ffd))
* **my-account:** sync email change with esp ([#3780](#3780)) ([983c087](983c087))
* **my-account:** sync email change with stripe ([#3789](#3789)) ([4f45795](4f45795))
* **woo-member-commenting:** optional module for member commenting ([#3783](#3783)) ([90746c8](90746c8))

### Reverts

* Revert "refactor(corrections): remove corrections feature flag (#3797)" (#3825) ([afd01f2](afd01f2)), closes [#3797](#3797) [#3825](#3825)
@matticbot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants