Make WordPress Core

Opened 10 months ago

Closed 5 months ago

Last modified 5 months ago

#59250 closed enhancement (fixed)

New Admin Email subject line should be filterable

Reported by: madtownlems's profile MadtownLems Owned by: audrasjb's profile audrasjb
Milestone: 6.5 Priority: normal
Severity: normal Version:
Component: Administration Keywords: good-first-bug has-patch has-unit-tests has-testing-info commit add-to-field-guide
Focuses: Cc:

Description

When a user attempts to update the Administration Email Address (Settings->Reading), they receive an email with a link they must click to confirm the change.

The body of the email is filterable (new_admin_email_content), but sadly the subject is not.

I'm proposing adding a new filter, such as new_admin_email_subject, that lets users customize this message.

For reference, I was looking to make it clearer that there is still action needed (to confirm the change), because I've seen LOTS of situations on our networks where these email updates are started - but never confirmed - likely due to the subject line sounding way more like a confirmation than something that requires action.

Attachments (4)

patch.diff (891 bytes) - added by alexanderkoledov 10 months ago.
patch.2.diff (891 bytes) - added by alexanderkoledov 10 months ago.
Filter "new_admin_email_subject" added
59520-with-tests.diff (1.8 KB) - added by shooper 9 months ago.
Patch including unit tests
59520-with-tests-and-comments.diff (2.0 KB) - added by shooper 8 months ago.
Updated the patch to include comments on the filter so that the Code Reference documentation is updated properly.

Download all attachments as: .zip

Change History (21)

#1 @johnbillion
10 months ago

  • Component changed from General to Administration
  • Keywords needs-patch good-first-bug added
  • Version trunk deleted

@alexanderkoledov
10 months ago

Filter "new_admin_email_subject" added

#2 @alexanderkoledov
10 months ago

  • Keywords has-patch added; needs-patch removed
Last edited 10 months ago by alexanderkoledov (previous) (diff)

@shooper
9 months ago

Patch including unit tests

#3 follow-up: @shooper
9 months ago

  • Keywords has-unit-tests has-testing-info needs-testing added

Testing Instructions

These steps define how to test the feature or enhancement, and indicates the expected behavior or results.

Steps to Test

  1. Add function to functions.php:
<?PHP
function updated_admin_email_subject() {
    return 'Filtered Admin Subject';
}
add_filter('new_admin_email_subject', 'updated_admin_email_subject');
  1. Login to to wp-admin dashboard
  2. Go to the Settings > General page
  3. Change the Administration Email Address
  4. Click on Save Changes

Expected Results

Lists each expected result or behavior, i.e. what should happen when running the test(s):

  • ✅ E-Mail Received with "Filtered Admin Subject" as the subject line

#4 @johnbillion
9 months ago

  • Milestone changed from Awaiting Review to 6.5

#5 @Marc_J
8 months ago

In a fresh WordPress 6.3.2 installation I applied the following patch.diff and added the code listed in the Testing Instructions. After changing the admin email address I received an email with the subject "Filtered Admin Subject".

In short: Works as expected ;-)

#6 @nikmeyer
8 months ago

On a local fresh WP installation (6.3.2) I tested patch.diff. I added the the testing Code in functions.php and after I changed the admin Email, I received the updated email Subject 'Filtered Admin Subject'.

Works like a charm :)

@shooper
8 months ago

Updated the patch to include comments on the filter so that the Code Reference documentation is updated properly.

#7 @xlthlx
7 months ago

I tested the https://core.trac.wordpress.org/attachment/ticket/59250/59520-with-tests-and-comments.diff on the WordPress Core trunk, and it works perfectly.

Just one note: the .diff patch, in this case, has to be applied to the src folder instead of the main folder (it would be fine if you are using a regular WordPress install).

#8 follow-up: @DaNish Ali
7 months ago

Hi @xlthlx

I can't find the tests in the src folder. I am using this https://github.com/WordPress/wordpress-develop repo, where should I add the code?

#9 in reply to: ↑ 8 @xlthlx
7 months ago

Replying to DaNish Ali:

Hi @danish-ali,
I hope I understood your question correctly: the tests are in the tests folder, not in the src one.

Hi @xlthlx

I can't find the tests in the src folder. I am using this https://github.com/WordPress/wordpress-develop repo, where should I add the code?

#10 @oglekler
7 months ago

@danish-ali When you are saving *.diff or *.patch into the root of the project, sometimes paths are not matching and instead of a command:

git apply 59520-with-tests-and-comments.diff

you have to make:

git apply --directory src 59520-with-tests-and-comments.diff

#11 in reply to: ↑ 3 @devmuhib
6 months ago

I added the function on theme functions.php file. But I guess the new subject is not applied.

https://prnt.sc/YvFm8hLZXxe-

Replying to shooper:

Testing Instructions

These steps define how to test the feature or enhancement, and indicates the expected behavior or results.

Steps to Test

  1. Add function to functions.php:
<?PHP
function updated_admin_email_subject() {
    return 'Filtered Admin Subject';
}
add_filter('new_admin_email_subject', 'updated_admin_email_subject');
  1. Login to to wp-admin dashboard
  2. Go to the Settings > General page
  3. Change the Administration Email Address
  4. Click on Save Changes

Expected Results

Lists each expected result or behavior, i.e. what should happen when running the test(s):

  • ✅ E-Mail Received with "Filtered Admin Subject" as the subject line

#12 @nuhel
5 months ago

In a fresh WordPress 6.4.2 installation I applied the following patch.diff and added the code listed in the Testing Instructions.

And it works perfectly.

This ticket was mentioned in PR #5865 on WordPress/wordpress-develop by @audrasjb.


5 months ago
#13

#14 @audrasjb
5 months ago

  • Keywords commit added; needs-testing removed
  • Owner set to audrasjb
  • Status changed from new to accepted

I tested the patch and it works fine.
Unit tests are passing.
Self assigning for commit.

#15 @audrasjb
5 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 57283:

Administration: Introduce new_admin_email_subject filter.

This changeset introduces the new_admin_email_subject hook which allow developers to filter the subject of the email sent when a change of site admin email address is attempted.

Props MadtownLems, johnbillion, alexanderkoledov, shooper, Marc_J, nikmeyer, xlthlx, devmuhib, nuhel, audrasjb.
Fixes #59250.

@audrasjb commented on PR #5865:


5 months ago
#16

committed

#17 @stevenlinx
5 months ago

  • Keywords add-to-field-guide added
Note: See TracTickets for help on using tickets.