Make WordPress Core

Opened 7 years ago

Last modified 4 weeks ago

#47004 assigned enhancement

WordPress email subject update - phase 2

Reported by: ramiy's profile ramiy Owned by: sirlouen's profile SirLouen
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Mail Keywords: has-patch has-test-info
Focuses: Cc:

Description

WordPress send emails, using wp_mail() function, to inform the site admin when some important tasks are done and when it needs user confirmation.

In #37940 we standardized email subjects used by WordPress. We updated subject texts, added unified translation comments and added site title as a prefix to all the email subjects.

Now we should standardized the filters used to filter WordPress emails. Why? Because not all emails can be filtered.

I prefer to do this in two steps:

  1. Separate the email subject from the wp_mail() function.
  2. Add new filters to filter the email subject.

See the attached patches.

Attachments (1)

47004.patch (8.6 KB) - added by ramiy 7 years ago.

Download all attachments as: .zip

Change History (21)

@ramiy
7 years ago

#1 @ramiy
7 years ago

  • Keywords has-patch added

This patch removed the email subject translation string from the wp_mail() functions into a separate $subject var.

I should mention that this conventions is used in other places in the code.

As a separate variable, we will be able to filter those email subjects.

#2 @johnbillion
7 years ago

  • Focuses administration removed
  • Type changed from defect (bug) to enhancement

Related:

Unofficial wp_mail() usage docs for reference: https://github.com/johnbillion/wp_mail

#3 @ramiy
7 years ago

@johnbillion Awesome job with the docs!

Let's try to promote the email tickets in 5.3 milestone.

#4 @ramiy
6 years ago

@johnbillion maybe 5.4 ?

#5 @pento
6 years ago

  • Owner pento deleted

#7 @SirLouen
3 months ago

  • Keywords dev-feedback added

I've been re-reviewing the current patch and the whole subjects list and I've found that most have been already been sorted during the past 6 years since this report was created.

These are the last remains. I've sent in a new patch, including the filters because it's a little extra effort to finally fulfill this requisite.

Although I have to say that the filters that have been deployed all over WP are extremely unorthodox, making it difficult to establish a common sense to hook to one or another (and forcing users to keep reviewing docs each single time one of those hooks wants to be used).

But things are how they are.

cc @johnbillion

#8 @SirLouen
3 months ago

  • Keywords needs-testing added; dev-feedback removed

#9 @SirLouen
3 months ago

  • Keywords has-test-info added

Testing instructions

If you want to test, simply add these two filters
delete_site_email_subject
and
newblog_notify_siteadmin_subject

And for the return of the callback, use a text that will be the new subject

For testing, the first filter:

  • Create a multisite WP
  • Create a new site
  • Then delete the site and check the incoming email. The subject will be your new subject in the filter.

For testing the other one.

  • Enable site creation by users (Settings ⇾ Networks Settings ⇾ Allow new registrations ⇾ Logged-in users may register new sites)
  • Create a new user and log with it.
  • Go to /wp-signup.php
  • Create a new site.

The check the incoming email. The subject must be the one you set in the filter.

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


3 months ago

#11 @abcd95
3 months ago

  • Keywords needs-testing removed

Test Report

Description

This report validates that the indicated patch works as expected, introducing new filters for various Multisite-related email subjects.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/9380

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.25
  • Server: nginx/1.27.2
  • Database: mysqli (Server: 8.4.4 / Client: mysqlnd 8.2.25)
  • Browser: Chrome 139.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0
    • WP Mail Logging 1.14.0

Actual Results

Without the patch: The filters do not exist.

With the patch applied:

✅ The new filter delete_site_email_subject works as expected when deleting a site from the network.

✅ The new filter newblog_notify_siteadmin_subject works as expected when a new site is created by a user.

✅ The new filter newuser_notify_siteadmin_subject works as expected when a new user registers on the network.

✅ The new filter new_user_email_subject works as expected when a user changes their email address from their profile.

Additional Notes

The following code was used to test the filters:

add_filter( 'delete_site_email_subject', function( $subject ) {
    return 'Hello World! - delete site';
} );

add_filter( 'newblog_notify_siteadmin_subject', function( $subject, $blog_id ) {
    return "Hello World! - new site";
}, 10, 2 );

add_filter( 'newuser_notify_siteadmin_subject', function( $subject, $user ) {
    return "Hello World! - new user";
}, 10, 2 );

add_filter( 'new_user_email_subject', function( $subject ) {
    return 'Hello World! - email change';
} );

Supplemental Artifacts

Delete Site -

https://i.ibb.co/DPvZyn1V/Screenshot-2025-08-12-at-16-32-31.png

New User -

https://i.ibb.co/jZ31x9Gx/Screenshot-2025-08-12-at-16-57-06.png

New Site -

https://i.ibb.co/xKCjJS6N/Screenshot-2025-08-12-at-16-58-01.png

Email Change -

https://i.ibb.co/cKyVG1pg/Screenshot-2025-08-12-at-17-11-27.png

This ticket was mentioned in Slack in #core-test by himanshu_pathak. View the logs.


3 months ago

#13 @SirLouen
3 months ago

  • Milestone changed from Awaiting Review to 6.9

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


2 months ago

#15 @pmbaldha
2 months ago

  • Keywords dev-feedback added

Test Report

Description

This report confirms that the proposed patch functions as intended, adding new filters for several Multisite-related email subjects.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/9380

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 140.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins:
    • test.php
  • Plugins:
    • Email Log 2.6
    • Test Reports 1.2.0

Actual Results

Without the patch:
The filters are not available.

With the patch applied:

✅ delete_site_email_subject — works as expected when deleting a site from the network.

✅ newblog_notify_siteadmin_subject — works as expected when a user creates a new site.

✅ newuser_notify_siteadmin_subject — works as expected when a new user registers on the network.

✅ new_user_email_subject — works as expected when a user updates their email address from their profile.

Additional Notes

The following code was used to test the filters:

<?php
add_filter( 'delete_site_email_subject', function( $subject ) {
    return 'Hello World! - delete site';
} );

add_filter( 'newblog_notify_siteadmin_subject', function( $subject, $blog_id ) {
    return "Hello World! - new site";
}, 10, 2 );

add_filter( 'newuser_notify_siteadmin_subject', function( $subject, $user ) {
    return "Hello World! - new user";
}, 10, 2 );

add_filter( 'new_user_email_subject', function( $subject ) {
    return 'Hello World! - email change';
} );

#16 @SirLouen
2 months ago

  • Keywords dev-feedback removed

This ticket was mentioned in Slack in #core by welcher. View the logs.


6 weeks ago

#18 @westonruter
4 weeks ago

  • Owner set to SirLouen

#19 @wildworks
4 weeks ago

  • Type changed from enhancement to feature request

The 6.9 Beta1 release will be released soon, but there has been no activity for over a month. I will change this ticket to feature-request.

#20 @wildworks
4 weeks ago

  • Milestone changed from 6.9 to Future Release
  • Type changed from feature request to enhancement

I will change this ticket to feature-request.

This was a mistake.

I will change the milestone on this ticket from 6.9 to Future Release.

Note: See TracTickets for help on using tickets.