Using WordPress ‘newuser_notify_siteadmin’ PHP filter

The newuser_notify_siteadmin WordPress PHP filter allows you to customize the message body of the new user activation email sent to the network administrator.

Usage

add_filter('newuser_notify_siteadmin', 'customize_newuser_email', 10, 2);

function customize_newuser_email($msg, $user) {
    // your custom code here
    return $msg;
}

Parameters

  • $msg (string) – The email body.
  • $user (WP_User) – WP_User instance of the new user.

More information

See WordPress Developer Resources: newuser_notify_siteadmin

Examples

Add custom message

Add a custom message to the new user email sent to the network administrator.

add_filter('newuser_notify_siteadmin', 'add_custom_message', 10, 2);

function add_custom_message($msg, $user) {
    $custom_message = "This is a custom message.";
    $msg .= "\n\n" . $custom_message;
    return $msg;
}

Add user’s display name

Include the new user’s display name in the email body.

add_filter('newuser_notify_siteadmin', 'add_display_name', 10, 2);

function add_display_name($msg, $user) {
    $msg .= "\n\nDisplay Name: " . $user->display_name;
    return $msg;
}

Add user’s email address

Include the new user’s email address in the email body.

add_filter('newuser_notify_siteadmin', 'add_email_address', 10, 2);

function add_email_address($msg, $user) {
    $msg .= "\n\nEmail Address: " . $user->user_email;
    return $msg;
}

Add user’s registration date

Include the new user’s registration date in the email body.

add_filter('newuser_notify_siteadmin', 'add_registration_date', 10, 2);

function add_registration_date($msg, $user) {
    $msg .= "\n\nRegistration Date: " . $user->user_registered;
    return $msg;
}

Remove the password reset link from the new user activation email.

add_filter('newuser_notify_siteadmin', 'remove_password_reset_link', 10, 1);

function remove_password_reset_link($msg) {
    $msg = preg_replace('/To set your password, visit the following address:(.*)\n/', '', $msg);
    return $msg;
}