The new_site_email WordPress PHP filter allows you to customize the content of the email sent to the Multisite network administrator when a new site is created.
Usage
add_filter('new_site_email', 'my_custom_new_site_email', 10, 3); function my_custom_new_site_email($new_site_email, $site, $user) { // your custom code here return $new_site_email; }
Parameters
$new_site_email
(array) – Used to build wp_mail() and contains:to
(string) – The email address of the recipient.subject
(string) – The subject of the email.message
(string) – The content of the email.headers
(string) – Headers.
$site
(WP_Site) – Site object of the new site.$user
(WP_User) – User object of the administrator of the new site.
More information
See WordPress Developer Resources: new_site_email
Examples
Change the email subject
add_filter('new_site_email', 'change_new_site_email_subject', 10, 3); function change_new_site_email_subject($new_site_email, $site, $user) { $new_site_email['subject'] = 'Welcome to our network!'; return $new_site_email; }
Add a custom message
add_filter('new_site_email', 'add_custom_message', 10, 3); function add_custom_message($new_site_email, $site, $user) { $custom_message = "Please review the new site and ensure everything is set up correctly."; $new_site_email['message'] .= "\n\n" . $custom_message; return $new_site_email; }
Set a custom recipient
add_filter('new_site_email', 'set_custom_recipient', 10, 3); function set_custom_recipient($new_site_email, $site, $user) { $new_site_email['to'] = '[email protected]'; return $new_site_email; }
Add custom headers
add_filter('new_site_email', 'add_custom_headers', 10, 3); function add_custom_headers($new_site_email, $site, $user) { $new_site_email['headers'] .= 'CC: [email protected]' . "\r\n"; return $new_site_email; }