Using WordPress ‘new_user_email_content’ PHP filter

The new_user_email_content WordPress PHP filter allows you to modify the text of the email sent when a user attempts to change their email address.

Usage

add_filter('new_user_email_content', 'customize_new_user_email_content', 10, 2);

function customize_new_user_email_content($email_text, $new_user_email) {
    // your custom code here
    return $email_text;
}

Parameters

  • $email_text (string) – Text in the email.
  • $new_user_email (array) – Data relating to the new user email address.
    • hash (string) – The secure hash used in the confirmation link URL.
    • newemail (string) – The proposed new email address.

More information

See WordPress Developer Resources: new_user_email_content

Examples

Change the email subject

Customize the email subject for the email change confirmation email.

function customize_new_user_email_subject($subject) {
    return "Confirm Your New Email Address";
}
add_filter('new_user_email_title', 'customize_new_user_email_subject');

Add a custom message to the email

Add a custom message to the email change confirmation email.

function customize_new_user_email_content($email_text, $new_user_email) {
    $custom_message = "Please confirm your new email address by clicking the link below.\n\n";
    return $custom_message . $email_text;
}
add_filter('new_user_email_content', 'customize_new_user_email_content', 10, 2);

Remove the site name from the email

Remove the site name from the email change confirmation email.

function customize_new_user_email_content($email_text, $new_user_email) {
    $email_text = str_replace('###SITENAME###', '', $email_text);
    return $email_text;
}
add_filter('new_user_email_content', 'customize_new_user_email_content', 10, 2);

Change the email signature

Change the email signature in the email change confirmation email.

function customize_new_user_email_content($email_text, $new_user_email) {
    $signature = "Best Regards,\nYour Custom Signature";
    $email_text = preg_replace('/\n\n--\n(.*)/', "\n\n--\n" . $signature, $email_text);
    return $email_text;
}
add_filter('new_user_email_content', 'customize_new_user_email_content', 10, 2);

Add a custom footer to the email change confirmation email.

function customize_new_user_email_content($email_text, $new_user_email) {
    $footer = "\n\nThis is a custom footer for the email change confirmation email.";
    return $email_text . $footer;
}
add_filter('new_user_email_content', 'customize_new_user_email_content', 10, 2);