wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

REST API: Fix api does not trigger new user notifications!

Open nikunj8866 opened this issue 10 months ago • 4 comments

Trac ticket: https://core.trac.wordpress.org/ticket/40477


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

nikunj8866 avatar Mar 24 '25 12:03 nikunj8866

Hi @nikunj8866! šŸ‘‹

Thank you for your contribution to WordPress! šŸ’–

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you, The WordPress Project

github-actions[bot] avatar Mar 24 '25 12:03 github-actions[bot]

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @[email protected].

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props nikunj8866, abcd95, spacedmonkey.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

github-actions[bot] avatar Mar 24 '25 12:03 github-actions[bot]

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @[email protected].

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

I want to use @nikunj8866 WordPress.org account for this PR.

nikunj8866 avatar Mar 24 '25 12:03 nikunj8866

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance, it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

github-actions[bot] avatar Mar 24 '25 12:03 github-actions[bot]

@nikunj8866 After investigation, I found that the notification is triggered in the multisite environments behaves differently, and an extra email is being triggered, which is failing the tests. https://github.com/WordPress/wordpress-develop/actions/runs/14440085345/job/40488175505?pr=8672

Can you please test if this change accounts for the multisite environments as well? Since there, the superadmin privileges also come into play.

himanshupathak95 avatar Apr 18 '25 07:04 himanshupathak95

@himanshupathak95 I've updated the PR to ensure that registration notifications are sent to both the user and the admin. The implementation now aligns with how WordPress core handles this for both single-site and multisite environments.

Specifically, I’m following the same approach as used in core: https://github.com/WordPress/wordpress-develop/blob/ec5bf32bd23df7abe100e1b8891f8d9be8685c07/src/wp-includes/default-filters.php#L524 https://github.com/WordPress/wordpress-develop/blob/ec5bf32bd23df7abe100e1b8891f8d9be8685c07/src/wp-includes/ms-default-filters.php#L30 https://github.com/WordPress/wordpress-develop/blob/ec5bf32bd23df7abe100e1b8891f8d9be8685c07/src/wp-includes/user.php#L3587

If this test failure is strictly due to multisite behavior, perhaps we can either skip the test for multisite scenarios or open a discussion in the core regarding how such notifications should behave across different environments.

nikunj8866 avatar Apr 18 '25 09:04 nikunj8866

@himanshupathak95 Password Changed email additional triggered for multisite.

image

nikunj8866 avatar Apr 18 '25 10:04 nikunj8866

@himanshupathak95 Password Changed email additional triggered for multisite.

Thanks @nikunj8866 for following up and testing this out.

However, ever after applying the latest commit, the tests are still failing. I am investigating this on my end.

himanshupathak95 avatar Apr 23 '25 08:04 himanshupathak95