10

When I add a new customer the email goes to new user in this format:

From: WordPress [wordpress@siteurl.com]
Subject: [site name] Your user name and password
Message:
         username: user
         Password: password
         siteurl.com/wp-login.php

Now I want to change this format Like this:

From: My Site Name [info@siteurl.com]
Subject: siteurl.com customer account activated
Message:
       Your customer account has been activated.

       Your Login credentials are:

       Username: user email
       Password: password

       Thanks,
       abcd

I tried this answer but it's not working.

How can i do this?

15

For 2018 and onwards users:

David Gard's answer still works but is old and there's a new better/cleaner way to do this (no need for a plugin anymore).

Since WordPress 4.9.0 there are new filters you can use to customise registration emails:

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;
}
7

The new user notification email is created and sent by the function wp_new_user_notification(), found in wp-includes/plugable.php

There is no filter hook within this funciton that will allow you to manipulate the output of the email, however you can of course overwrite any pluggable function via a plugin.

Note - You can only overwrite pluggable functions from within a plugin, not from within your theme.

See here for more details on pluggable functions and a full list of those available - http://codex.wordpress.org/Pluggable_Functions

This code will create the plugin which will be used instead of the one in wp-includes/plugable.php (save it in its own file in wp-content/plugins/).

I haven't customised it for you, but this should get you on your way.

<?php
/**
 * Plugin Name: Custom new user notification email
 * Description: Overwrites the pluggable 'wp_new_user_notification()' plugin to allow the sending of a custom email
 * Author: David Gard
 * Version: 1.0
 */

if ( !function_exists('wp_new_user_notification') ) :
/**
 * Pluggable - Email login credentials to a newly-registered user
 *
 * A new user registration notification is also sent to admin email.
 *
 * @since 2.0.0
 *
 * @param int    $user_id        User ID.
 * @param string $plaintext_pass Optional. The user's plaintext password. Default empty.
 */
function wp_new_user_notification($user_id, $plaintext_pass = ''){

    $user = get_userdata($user_id);

    // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    // we want to reverse this for the plain text arena of emails.
    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

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

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

    if ( empty($plaintext_pass) )
        return;

    $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    $message .= wp_login_url() . "\r\n";

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

}
endif;
1

If you are referring to a multisite setup, this is configurable through a template that is set up in the database under 2 sections:

Welcome Email

and

Welcome User Email

http://yoursite/wp-admin/network/settings.php

You can customize it to your liking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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