Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've set the 'Welcome User Email' under 'New Site Settings' to the following:

Dear USERNAME: Welcome to the SITE_NAME portal which provides information on our policies, processes, >procedures, templates and forms. You can also view the SITE_NAME news, calendar and >contacts.

Here is your login information: Username:USERNAME Password: PASSWORD

Click here to log in - LOGINLINK

The problem is that when the user receives the email, the "SITE_NAME" parameter is the 'network name' for the wordpress install, not the name of the actual blog they have just registered to.

This code https://gist.github.com/1331582 overcomes the issue for the user confirmation email that initially gets sent out when a user is added, but I need it to apply to the 'Welcome User Email'.

Thanks, Brad

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

The technique is basically the same as in the case of wpmu_signup_user_notification().

function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
    global $current_site;

    $welcome_email = get_site_option( 'welcome_user_email' );

    $user = new WP_User($user_id);

    $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta);

    // Get the current blog name
    $blogname = get_option( 'blogname' );
    $welcome_email = str_replace( 'SITE_NAME', $blogname, $welcome_email );

    $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
    $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
    $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );

    $admin_email = get_site_option( 'admin_email' );

    if ( $admin_email == '' )
         $admin_email = 'support@' . $_SERVER['SERVER_NAME'];

    $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    $message = $welcome_email;

    $subject = apply_filters( 'update_welcome_user_subject', sprintf(__('New %1$s User: %2$s'), $blogname, $user->user_login) );
    wp_mail($user->user_email, $subject, $message, $message_headers);

    return false; // make sure wpmu_welcome_user_notification() doesn't keep running
}
add_filter( 'wpmu_welcome_user_notification', 'bbg_wpmu_welcome_user_notification', 10, 3 );
share|improve this answer
    
Legend! I just needed to tweak the function to bbg_wpmu_welcome_user_notification so it was the same as being called in the add_filter. Thanks! –  Brad Farleigh Mar 22 '12 at 1:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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