Skip to content

Send email notification when an application password is added - #9795

Closed
prasadkarmalkar wants to merge 8 commits into
WordPress:trunkfrom
prasadkarmalkar:trac-63927
Closed

Send email notification when an application password is added#9795
prasadkarmalkar wants to merge 8 commits into
WordPress: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

github-actions Bot commented Sep 8, 2025

Copy link
Copy Markdown

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, audrasjb.

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

@github-actions

github-actions Bot commented Sep 8, 2025

Copy link
Copy Markdown

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.

@johnbillion johnbillion 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.

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.

@johnbillion

Copy link
Copy Markdown
Member

@prasadkarmalkar I adjusted the text of the email so it's closer to the password reset email text. What do you think?

@johnbillion
johnbillion requested a review from audrasjb September 1, 2026 12:09

@audrasjb audrasjb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both the technical implementation and the email content look good to me.
I compared the email with other emails already sent by WP, I think it's consistent.
👍

wporg-sync pushed a commit that referenced this pull request Sep 10, 2026
…ssword is added.

This introduces a filterable email notification so users get alerted when an application password is added to their account.

The email can be filtered via the `wp_application_password_created_email` filter and disabled via the `wp_send_application_password_created_email` filter.

Props prasadkarmalkar, johnbillion, audrasjb.

Developed in #9795

Fixes #63927


git-svn-id: https://develop.svn.wordpress.org/trunk@63582 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 63582
GitHub commit: 032936f

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Sep 10, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 10, 2026
…ssword is added.

This introduces a filterable email notification so users get alerted when an application password is added to their account.

The email can be filtered via the `wp_application_password_created_email` filter and disabled via the `wp_send_application_password_created_email` filter.

Props prasadkarmalkar, johnbillion, audrasjb.

Developed in WordPress/wordpress-develop#9795

Fixes #63927

Built from https://develop.svn.wordpress.org/trunk@63582


git-svn-id: http://core.svn.wordpress.org/trunk@62758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.

3 participants