wpmu_welcome_user_notification

Notify a user that their account activation has been successful.

Description

wpmu_welcome_user_notification( (int) $user_id, (string) $password, (array) $meta = array() ); 

Filter to disable or bypass.

Filter and to modify the content and subject line of the notification email.

Parameters (3)

0. $user_id (int)
The user id.
1. $password (string)
The password.
2. $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_user_notification' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // The password. 
  8. $password = ''; 
  9.  
  10. // Optional. Not used in the default function, but is passed along to hooks for customization. 
  11. $meta = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wpmu_welcome_user_notification($user_id, $password, $meta); 
  15.  

Defined (1)

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

/wp-includes/ms-functions.php  
  1. function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) { 
  2. $current_network = get_network(); 
  3.  
  4. /** 
  5. * Filters whether to bypass the welcome email after user activation. 
  6. * Returning false disables the welcome email. 
  7. * @since MU 
  8. * @param int $user_id User ID. 
  9. * @param string $password User password. 
  10. * @param array $meta Signup meta data. 
  11. */ 
  12. if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) 
  13. return false; 
  14.  
  15. $welcome_email = get_site_option( 'welcome_user_email' ); 
  16.  
  17. $user = get_userdata( $user_id ); 
  18.  
  19. $switched_locale = switch_to_locale( get_user_locale( $user ) ); 
  20.  
  21. /** 
  22. * Filters the content of the welcome email after user activation. 
  23. * Content should be formatted for transmission via wp_mail(). 
  24. * @since MU 
  25. * @param string $welcome_email The message body of the account activation success email. 
  26. * @param int $user_id User ID. 
  27. * @param string $password User password. 
  28. * @param array $meta Signup meta data. 
  29. */ 
  30. $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta ); 
  31. $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email ); 
  32. $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email ); 
  33. $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email ); 
  34. $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email ); 
  35.  
  36. $admin_email = get_site_option( 'admin_email' ); 
  37.  
  38. if ( $admin_email == '' ) 
  39. $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 
  40.  
  41. $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 
  42. $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 
  43. $message = $welcome_email; 
  44.  
  45. if ( empty( $current_network->site_name ) ) 
  46. $current_network->site_name = 'WordPress'; 
  47.  
  48. /** translators: New user notification email subject. 1: Network name, 2: New user login */ 
  49. $subject = __( 'New %1$s User: %2$s' ); 
  50.  
  51. /** 
  52. * Filters the subject of the welcome email after user activation. 
  53. * @since MU 
  54. * @param string $subject Subject of the email. 
  55. */ 
  56. $subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login) ); 
  57. wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); 
  58.  
  59. if ( $switched_locale ) { 
  60.  
  61. return true;