Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
1  
You have a very low accept rate - you might find that your questions are answered more quickly if you take a moment to go back and accept answers, or comment on why they're not good, – anu Apr 21 '11 at 10:32
1  
Ok thanks for the advice – mike23 Apr 21 '11 at 11:07
You deleted your answer and changed the question, that's a little abrupt don't you think ? I'm not looking specifically for a non-plugin solution.. I don't get it man.. you're after the points or sth ? – mike23 Apr 21 '11 at 11:34
You want a non-plugin solution, I don't see what's contentious about that. I don't know what sth means. – anu Apr 21 '11 at 12:00
I cannot beleive we're doing this. Can you please repost your answer? I'll give you the green tick I promise. – mike23 Apr 21 '11 at 12:32

1 Answer

up vote 22 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);

    }
}
share|improve this answer
Great thanks Bainternet ! – mike23 Apr 23 '11 at 16:38
@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? – Piet Jul 2 '11 at 2:33
3  
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! – Piet Jul 2 '11 at 3:03

protected by toscho Oct 11 '12 at 1:46

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

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