wpmu_welcome_notification
Notify a user that their blog activation has been successful.
Description
wpmu_welcome_notification( (int) $blog_id, (int) $user_id, (string) $password, (string) $title, (array) $meta = array() );
Filter to disable or bypass.
Filter and to modify the content and subject line of the notification email.
Parameters (5)
- 0. $blog_id (int)
- The blog id.
- 1. $user_id (int)
- The user id.
- 2. $password (string)
- The password.
- 3. $title (string)
- The new blog's title
- 4. $meta — Optional. (array) =>
array()
- Not used in the default function, but is passed along to hooks for customization.
Usage
if ( !function_exists( 'wpmu_welcome_notification' ) ) { require_once ABSPATH . WPINC . '/ms-functions.php'; } // The blog id. $blog_id = -1; // The user id. $user_id = -1; // The password. $password = ''; // The new blog's title $title = ''; // Optional. Not used in the default function, but is passed along to hooks for customization. $meta = array(); // NOTICE! Understand what this does before running. $result = wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/ms-functions.php
- function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
- $current_network = get_network();
- /**
- * Filters whether to bypass the welcome email after site activation.
- *
- * Returning false disables the welcome email.
- *
- * @since MU
- *
- * @param int|bool $blog_id Blog ID.
- * @param int $user_id User ID.
- * @param string $password User password.
- * @param string $title Site title.
- * @param array $meta Signup meta data.
- */
- if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) )
- return false;
- $user = get_userdata( $user_id );
- $switched_locale = switch_to_locale( get_user_locale( $user ) );
- $welcome_email = get_site_option( 'welcome_email' );
- if ( $welcome_email == false ) {
- /** translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
- $welcome_email = __( 'Howdy USERNAME,
- Your new SITE_NAME site has been successfully set up at:
- BLOG_URL
- You can log in to the administrator account with the following information:
- Username: USERNAME
- Password: PASSWORD
- Log in here: BLOG_URLwp-login.php
- We hope you enjoy your new site. Thanks!
- --The Team @ SITE_NAME' );
- }
- $url = get_blogaddress_by_id($blog_id);
- $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
- $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
- $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
- $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
- $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
- /**
- * Filters the content of the welcome email after site activation.
- *
- * Content should be formatted for transmission via wp_mail().
- *
- * @since MU
- *
- * @param string $welcome_email Message body of the email.
- * @param int $blog_id Blog ID.
- * @param int $user_id User ID.
- * @param string $password User password.
- * @param string $title Site title.
- * @param array $meta Signup meta data.
- */
- $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
- $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;
- if ( empty( $current_network->site_name ) )
- $current_network->site_name = 'WordPress';
- /** translators: New site notification email subject. 1: Network name, 2: New site name */
- $subject = __( 'New %1$s Site: %2$s' );
- /**
- * Filters the subject of the welcome email after site activation.
- *
- * @since MU
- *
- * @param string $subject Subject of the email.
- */
- $subject = apply_filters( 'update_welcome_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) );
- wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
- if ( $switched_locale ) {
- }
- return true;
- }