Using WordPress ‘newblog_notify_siteadmin’ PHP filter

The newblog_notify_siteadmin WordPress PHP filter modifies the message body of the new site activation email sent to the network administrator.

Usage

add_filter('newblog_notify_siteadmin', 'customize_newblog_email_body', 10, 2);
function customize_newblog_email_body($msg, $blog_id) {
    // your custom code here

    return $msg;
}

Parameters

  • $msg (string): The original email body.
  • $blog_id (int|string): The new site’s ID as an integer or numeric string.

More information

See WordPress Developer Resources: newblog_notify_siteadmin

Examples

Add a custom message to the email body

Customize the email body by adding a custom message.

add_filter('newblog_notify_siteadmin', 'add_custom_message', 10, 2);
function add_custom_message($msg, $blog_id) {
    $custom_message = "Welcome to our network!";
    $msg .= "\n\n" . $custom_message;

    return $msg;
}

Include the new site’s URL in the email

Display the new site’s URL in the email body.

add_filter('newblog_notify_siteadmin', 'include_site_url', 10, 2);
function include_site_url($msg, $blog_id) {
    $site_url = get_blog_details($blog_id)->siteurl;
    $msg .= "\n\nNew site URL: " . $site_url;

    return $msg;
}

Add a signature to the email body

Add a custom signature to the email body.

add_filter('newblog_notify_siteadmin', 'add_email_signature', 10, 2);
function add_email_signature($msg, $blog_id) {
    $signature = "Best Regards,\nThe Network Team";
    $msg .= "\n\n" . $signature;

    return $msg;
}

Include the site owner’s email address

Display the site owner’s email address in the email body.

add_filter('newblog_notify_siteadmin', 'include_owner_email', 10, 2);
function include_owner_email($msg, $blog_id) {
    $owner_email = get_blog_details($blog_id)->admin_email;
    $msg .= "\n\nSite Owner Email: " . $owner_email;

    return $msg;
}

Change the email format to HTML

Convert the email body to an HTML format.

add_filter('newblog_notify_siteadmin', 'html_email_body', 10, 2);
function html_email_body($msg, $blog_id) {
    $msg = nl2br($msg);
    $msg = "<html><body>" . $msg . "</body></html>";

    return $msg;
}