Added Filter to be possible to disable/change the 'New Site Created' email sent to Administration email address
|Reported by:||vaurdan||Owned by:|
While doing my WordPress work, I found the need of disable all the WordPress Multisite notification emails that are sent to the administrator. But one mail keep being sent: "[Sitename] New Site Created".
I decided to analyse the core's code, and found that the email was being sent on line 91, of wp-admin/network/site-new.php, and there was no filter to disable it (it was just a wp_mail call).
$content_mail = sprintf( __( 'New site created by %1$s Address: %2$s Name: %3$s' ), $current_user->user_login , get_site_url( $id ), wp_unslash( $title ) ); wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
Since I guess that this should be filtered, I decided to create a new filter, by replacing that lines with a single function call:
$user_name = $current_user->user_login; $address = get_site_url( $id ); wpmu_admin_new_site_notification( $user_name, $address, $title );
The new wpmu_admin_new_site_notification that I created, is declared on wp-includes/ms-functions.php and it as simple as a function that send an email to the administrator, and that have three filters: wpmu_admin_new_site_notification that can be used to bypass the email; update_new_site_notification_email that can change the content of the emaiil; and update_new_site_notification_subject that can be used to change the subject of the email.
You can see more details of this on the .patch file I submitted, with commented code.
Change History (12)
comment:2 follow-up: ↓ 3 @jeremyfelt — 18 months ago
- Milestone changed from Awaiting Review to 3.9
- Version changed from 3.8 to 3.0
comment:5 @jeremyfelt — 16 months ago
- Component changed from Multisite to Mail
- Focuses multisite added