0

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

1 Answer 1

1

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 );
1
  • 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! Mar 22, 2012 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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