After a new user registration, WP sends out an email with the login / password, and a link to the login page.

Is there a way to change this defaut email template? I'd also like to change the subject and sender.

Edit : For anyone interested, here is a plugin solution.

up vote 59 down vote accepted

the new user email is sent using wp_new_user_notification() function which is pluggable meaning that you can overwrite it:

// Redefine user notification function
if ( !function_exists('wp_new_user_notification') ) {
    function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
        $user = new WP_User($user_id);

        $user_login = stripslashes($user->user_login);
        $user_email = stripslashes($user->user_email);

        $message  = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n";
        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
        $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";

        @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);

        if ( empty($plaintext_pass) )
            return;

        $message  = __('Hi there,') . "\r\n\r\n";
        $message .= sprintf(__("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
        $message .= wp_login_url() . "\r\n";
        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
        $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n\r\n";
        $message .= sprintf(__('If you have any problems, please contact me at %s.'), get_option('admin_email')) . "\r\n\r\n";
        $message .= __('Adios!');

        wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);

    }
}
  • @Bainternet I cannot seem to get this to work, I have added this to my functions file, but the standard email keeps sending. I'm on multisite, but that shouldn't matter, right? – George Jul 2 '11 at 2:33
  • 6
    OK got it now, it only seems to work as a separate plugin, not when you add it to your functions.php file. Now it works perfect, thanks again for that nice piece of code! – George Jul 2 '11 at 3:03
  • Does it works for multisite too? I can see multisite has bunch of functions inside ms-functions.php for sending notification email. – Sisir Jul 28 '13 at 7:42
  • Multisite uses wpmu_signup_user_notification I think. – Wyck Nov 25 '14 at 21:43
  • This answer is several years old. The accepted answer doesn't work for me. (Adding it to functions.php has makes no difference to any of the emails sent when a new user registers.) Should I post a new question? – Kit Johnson Apr 21 '15 at 11:23

For 2018 and onwards users:

Since WordPress 4.9.0 there are new filters you can use for this (no need for a plugin anymore):

Usage example on email sent to Admin (you can paste this in your theme's functions.php ):

add_filter( 'wp_new_user_notification_email_admin', 'custom_wp_new_user_notification_email', 10, 3 );

function custom_wp_new_user_notification_email( $wp_new_user_notification_email, $user, $blogname ) {
    $wp_new_user_notification_email['subject'] = sprintf( '[%s] New user %s registered.', $blogname, $user->user_login );
    $wp_new_user_notification_email['message'] = sprintf( "%s ( %s ) has registerd to your blog %s.", $user->user_login, $user->user_email, $blogname );
    return $wp_new_user_notification_email;
}
  • Alternatively one could use the wp_new_user_notification_email and wp_new_user_notification_email_admin filters. Those interested can check out the full documentation and source code for wp_new_user_notification(). – Pete Jan 10 at 3:42
  • Thanks Pete, looks like that was introduced in 4.9.0 and looks like a better solution. – Edu Wass Jan 10 at 12:24

This will don't work on functions.php, you need to put this code inside plugin.

if you don't now to make a plugin for this just use this link

don't forget to take the update code of this function form here

protected by fuxia Oct 11 '12 at 1:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.