Skip to content

Send email notification when an application password is added#9795

Open
prasadkarmalkar wants to merge 3 commits intoWordPress:trunkfrom
prasadkarmalkar:trac-63927
Open

Send email notification when an application password is added#9795
prasadkarmalkar wants to merge 3 commits intoWordPress:trunkfrom
prasadkarmalkar:trac-63927

Conversation

@prasadkarmalkar
Copy link
Copy Markdown

This pull request enhances WordPress security by notifying users via email whenever a new application password is added to their account.

  • Sends an email to the user’s registered email address immediately after an application password is created.
  • The email includes the name of the application password and site details, and advises the user to review their account if the creation was unexpected.

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


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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 8, 2025

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.

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

Props prasadkarmalkar, johnbillion.

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 8, 2025

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.

Copy link
Copy Markdown
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @prasadkarmalkar!

If you're willing to keep working on this then I have some feedback that I think will greatly improve this implementation. In general, this should look more like the existing wp_site_admin_email_change_notification() function. This means:

  1. This addition should be encapsulated into a new function that is hooked into the wp_create_application_password action, probably in default-filters.php and with the function itself in wp-includes/user.php.
  2. A filter such as send_application_password_created_email should be added so conditional logic can be performed to decide whether to send the email. See send_site_admin_email_change_email as as example.
  3. The email contents should use ###FIELD### placeholders instead of numbered placeholders to make the string easier to translate and more maintainable in the future.
  4. The email parameters (to, subject, message, headers) should all pass through a filter. See site_admin_email_change_email as an example.

@prasadkarmalkar
Copy link
Copy Markdown
Author

Hi @johnbillion, Thanks for the suggestions. I have updated the code as per the requested changes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants