WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 5 weeks ago

#42134 reviewing enhancement

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

Reported by: johnbillion Owned by: johnbillion
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: good-first-bug has-patch
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 (3)

42134.patch (6.3 KB) - added by Dhruvin 2 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 2 years ago.
better patch with placeholders and some other improvements
42134.3.patch (4.2 KB) - added by dharmin16 13 months 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.

Download all attachments as: .zip

Change History (14)

@Dhruvin
2 years ago

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

#2 @Dhruvin
2 years ago

  • Keywords has-patch added; needs-patch removed

#3 @johnbillion
2 years ago

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

#4 @johnbillion
2 years ago

  • Milestone changed from Awaiting Review to 5.0

@Dharm1025
2 years ago

better patch with placeholders and some other improvements

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


22 months ago

@dharmin16
13 months 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
11 months ago

  • Milestone changed from 5.0 to 5.1

#7 @pento
8 months ago

  • Milestone changed from 5.1 to 5.2

#8 @desrosj
6 months ago

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

These patches need to be reviewed and tested.

#9 @jipmoors
3 months 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 3 months ago by jipmoors (previous) (diff)

#10 @jipmoors
3 months ago

  • Keywords needs-testing removed

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


5 weeks ago

Note: See TracTickets for help on using tickets.