WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 8 months ago

Last modified 6 months ago

#42134 closed enhancement (fixed)

Add filter to emails sent by wp-admin/network/site-new.php

Reported by: johnbillion Owned by: johnbillion
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: good-first-bug has-patch commit has-dev-note
Focuses: multisite Cc:

Description

wp-admin/network/site-new.php contains a call to wp_mail() which sends an email when a new site is created from Network Admin -> Sites -> Add New on Multisite. (Ref).

The contents of the email cannot be filtered. The recipient, subject, message, and headers should be passed through a filter in the same format as the password_change_email filter. (Ref).

Attachments (4)

42134.patch (6.3 KB) - added by Dhruvin 4 years ago.
Added a filter for filtering the contents of the email sent when a new site is created.
42134.2.patch (3.4 KB) - added by Dharm1025 4 years ago.
better patch with placeholders and some other improvements
42134.3.patch (4.2 KB) - added by dharmin16 3 years ago.
added the feature simmilar to wp_welcome_message(). E.g. Filter 'wpmu_admin_notification' to disable or bypass. Filter 'update_admin_notification' and 'update_admin_notification_subject'} to modify the content and subject line of the notification email.
42134.diff (4.7 KB) - added by johnbillion 9 months ago.

Download all attachments as: .zip

Change History (25)

@Dhruvin
4 years ago

Added a filter for filtering the contents of the email sent when a new site is created.

#2 @Dhruvin
4 years ago

  • Keywords has-patch added; needs-patch removed

#3 @johnbillion
4 years ago

  • Owner set to johnbillion
  • Status changed from new to reviewing

#4 @johnbillion
4 years ago

  • Milestone changed from Awaiting Review to 5.0

@Dharm1025
4 years ago

better patch with placeholders and some other improvements

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


4 years ago

@dharmin16
3 years ago

added the feature simmilar to wp_welcome_message(). E.g. Filter 'wpmu_admin_notification' to disable or bypass. Filter 'update_admin_notification' and 'update_admin_notification_subject'} to modify the content and subject line of the notification email.

#6 @johnbillion
3 years ago

  • Milestone changed from 5.0 to 5.1

#7 @pento
2 years ago

  • Milestone changed from 5.1 to 5.2

#8 @desrosj
2 years ago

  • Keywords needs-testing added
  • Milestone changed from 5.2 to 5.3

These patches need to be reviewed and tested.

#9 @jipmoors
2 years ago

Looking at the code I'm seeing some places that can be improved. As this is a stand-alone function better checking for unexpected situation will improve functionality.

  • get_userdata can return unexpected data, as the user ID doesn't have to be valid
  • $admin_notification is being determined using a filter, which can return an empty value; an email should not be send if there is no message

Site tite:
Title is being provided as an argument to the function, but $current_network->site_name is being used instead.
In this implementation $current_network->site_name is being set to a value, this might have unwanted side-effects.

Some other concern I noticed:
The admin_email will be default in this patch to: 'support@' . $_SERVER['SERVER_NAME']
But support is not a default emailbox. Suggesting to use "postmaster" or even considering of returning a WP_Error and not sending an email at all.

Last edited 2 years ago by jipmoors (previous) (diff)

#10 @jipmoors
2 years ago

  • Keywords needs-testing removed

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


22 months ago

#12 @desrosj
21 months ago

  • Keywords needs-refresh added
  • Milestone changed from 5.3 to Future Release

This still needs some work. With 5.3 beta 1 in a few hours, it needs to be punted.

#13 @johnbillion
9 months ago

  • Milestone changed from Future Release to 5.6

#14 @johnbillion
9 months ago

#42135 was marked as a duplicate.

@johnbillion
9 months ago

#15 @johnbillion
9 months ago

  • Keywords commit added

42134.diff continues on from the patches here and on #42135.

  • Improved naming and structure of the filters
  • Avoid passing unnecessary parameters such as the site title, as this can be gotten from the site option
  • Pass the complete site and user objects to the filters
  • Correctly switch to the locale of the user associated with the network admin email address, falling back to the locale of the site if there isn't one

This is looking good to me now.

#16 @davidbaumwald
8 months ago

  • Keywords needs-refresh removed

#17 @johnbillion
8 months ago

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

In 49127:

Networks and Sites: Extract into a new function the email that gets sent to the network administrator when a new site is created, and introduce filters to disable and modify its

contents.

  • The send_new_site_email filter can be used to disable this email.
  • The new_site_email filter can be used to modify its contents.

Props Dhruvin, Dharm1025, dharmin16, jipmoors

Fixes #42134

#18 @SergeyBiryukov
8 months ago

In 49130:

Docs: Correct comments in wpmu_new_site_admin_notification() per the documentation standards.

See #42134.

#19 @desrosj
7 months ago

  • Keywords needs-dev-note added

Let's note this new filter in the miscellaneous dev note.

#21 @dharmin16
6 months ago

#44781 was marked as a duplicate.

Note: See TracTickets for help on using tickets.