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

  1. if ( !function_exists( 'wpmu_welcome_notification' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // The blog id. 
  5. $blog_id = -1; 
  6.  
  7. // The user id. 
  8. $user_id = -1; 
  9.  
  10. // The password. 
  11. $password = ''; 
  12.  
  13. // The new blog's title 
  14. $title = ''; 
  15.  
  16. // Optional. Not used in the default function, but is passed along to hooks for customization. 
  17. $meta = array(); 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta); 
  21.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-functions.php  
  1. function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) { 
  2. $current_network = get_network(); 
  3.  
  4. /** 
  5. * Filters whether to bypass the welcome email after site activation. 
  6. * Returning false disables the welcome email. 
  7. * @since MU 
  8. * @param int|bool $blog_id Blog ID. 
  9. * @param int $user_id User ID. 
  10. * @param string $password User password. 
  11. * @param string $title Site title. 
  12. * @param array $meta Signup meta data. 
  13. */ 
  14. if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) 
  15. return false; 
  16.  
  17. $user = get_userdata( $user_id ); 
  18.  
  19. $switched_locale = switch_to_locale( get_user_locale( $user ) ); 
  20.  
  21. $welcome_email = get_site_option( 'welcome_email' ); 
  22. if ( $welcome_email == false ) { 
  23. /** translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ 
  24. $welcome_email = __( 'Howdy USERNAME,  
  25.  
  26. Your new SITE_NAME site has been successfully set up at: 
  27. BLOG_URL 
  28.  
  29. You can log in to the administrator account with the following information: 
  30.  
  31. Username: USERNAME 
  32. Password: PASSWORD 
  33. Log in here: BLOG_URLwp-login.php 
  34.  
  35. We hope you enjoy your new site. Thanks! 
  36.  
  37. --The Team @ SITE_NAME' ); 
  38.  
  39. $url = get_blogaddress_by_id($blog_id); 
  40.  
  41. $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email ); 
  42. $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email ); 
  43. $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email ); 
  44. $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); 
  45. $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); 
  46.  
  47. /** 
  48. * Filters the content of the welcome email after site activation. 
  49. * Content should be formatted for transmission via wp_mail(). 
  50. * @since MU 
  51. * @param string $welcome_email Message body of the email. 
  52. * @param int $blog_id Blog ID. 
  53. * @param int $user_id User ID. 
  54. * @param string $password User password. 
  55. * @param string $title Site title. 
  56. * @param array $meta Signup meta data. 
  57. */ 
  58. $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta ); 
  59. $admin_email = get_site_option( 'admin_email' ); 
  60.  
  61. if ( $admin_email == '' ) 
  62. $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 
  63.  
  64. $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 
  65. $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 
  66. $message = $welcome_email; 
  67.  
  68. if ( empty( $current_network->site_name ) ) 
  69. $current_network->site_name = 'WordPress'; 
  70.  
  71. /** translators: New site notification email subject. 1: Network name, 2: New site name */ 
  72. $subject = __( 'New %1$s Site: %2$s' ); 
  73.  
  74. /** 
  75. * Filters the subject of the welcome email after site activation. 
  76. * @since MU 
  77. * @param string $subject Subject of the email. 
  78. */ 
  79. $subject = apply_filters( 'update_welcome_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) ); 
  80. wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); 
  81.  
  82. if ( $switched_locale ) { 
  83.  
  84. return true;