wpmu_signup_user_notification

Notify user of signup success.

Description

wpmu_signup_user_notification( (string) $user_login, (string) $user_email, (string) $key, (array) $meta = array() ); 

This is the notification function used when no new site has been requested.

Filter to bypass this function or replace it with your own notification behavior.

Filter and to change the content and subject line of the email sent to newly registered users.

Parameters (4)

0. $user_login (string)
The user's login name.
1. $user_email (string)
The user's email address.
2. $key (string)
The activation key created in wpmu_signup_user()
3. $meta — Optional. (array) => array()
By default, an empty array.

Usage

  1. if ( !function_exists( 'wpmu_signup_user_notification' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // The user's login name. 
  5. $user_login = ''; 
  6.  
  7. // The user's email address. 
  8. $user_email = ''; 
  9.  
  10. // The activation key created in wpmu_signup_user() 
  11. $key = ''; 
  12.  
  13. // By default, an empty array. 
  14. $meta = array(); 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wpmu_signup_user_notification($user_login, $user_email, $key, $meta); 
  18.  

Defined (1)

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

/wp-includes/ms-functions.php  
  1. function wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = array() ) { 
  2. /** 
  3. * Filters whether to bypass the email notification for new user sign-up. 
  4. * @since MU 
  5. * @param string $user_login User login name. 
  6. * @param string $user_email User email address. 
  7. * @param string $key Activation key created in wpmu_signup_user(). 
  8. * @param array $meta Signup meta data. 
  9. */ 
  10. if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) 
  11. return false; 
  12.  
  13. $user = get_user_by( 'login', $user_login ); 
  14. $switched_locale = switch_to_locale( get_user_locale( $user ) ); 
  15.  
  16. // Send email with activation link. 
  17. $admin_email = get_site_option( 'admin_email' ); 
  18. if ( $admin_email == '' ) 
  19. $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 
  20. $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 
  21. $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 
  22. $message = sprintf( 
  23. /** 
  24. * Filters the content of the notification email for new user sign-up. 
  25. * Content should be formatted for transmission via wp_mail(). 
  26. * @since MU 
  27. * @param string $content Content of the notification email. 
  28. * @param string $user_login User login name. 
  29. * @param string $user_email User email address. 
  30. * @param string $key Activation key created in wpmu_signup_user(). 
  31. * @param array $meta Signup meta data. 
  32. */ 
  33. __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),  
  34. $user_login, $user_email, $key, $meta 
  35. ),  
  36. site_url( "wp-activate.php?key=$key" ) 
  37. ); 
  38. // TODO: Don't hard code activation link. 
  39. $subject = sprintf( 
  40. /** 
  41. * Filters the subject of the notification email of new user signup. 
  42. * @since MU 
  43. * @param string $subject Subject of the notification email. 
  44. * @param string $user_login User login name. 
  45. * @param string $user_email User email address. 
  46. * @param string $key Activation key created in wpmu_signup_user(). 
  47. * @param array $meta Signup meta data. 
  48. */ 
  49. /** translators: New user notification email subject. 1: Network name, 2: New user login */ 
  50. _x( '[%1$s] Activate %2$s', 'New user notification email subject' ),  
  51. $user_login, $user_email, $key, $meta 
  52. ),  
  53. $from_name,  
  54. $user_login 
  55. ); 
  56. wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers ); 
  57.  
  58. if ( $switched_locale ) { 
  59.  
  60. return true;