Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. function send_welcome_email_to_new_user($user_id) {
  2.     $user = get_userdata($user_id);
  3.     $user_email = $user->user_email;
  4.  
  5. // email will send only for "health_pro" registers
  6. if ( in_array( 'customer', $user->roles, true ) {
  7.   $to = $user_email;
  8.   $subject = "Hi customer, welcome to our site!";
  9.   $body = '
  10.            <h1>Dear customer,</h1></br>
  11.            <p>Thank you for joining our site. Your account is now active.</p>
  12.            <p>Please go ahead and navigate around your account.</p>
  13.            <p>Let me know if you have further questions, I am here to help.</p>
  14.            <p>Enjoy the rest of your day!</p>
  15.            <p>Kind Regards,</p>
  16.            <p>customer</p>
  17.  ';
  18.   $headers = array('Content-Type: text/html; charset=UTF-8');
  19.   if (wp_mail($to, $subject, $body, $headers)) {
  20.     error_log("email has been successfully sent to user whose email is " . $user_email);
  21.   }
  22. }
  23.  
  24. // email will send only for "health_pro" registers
  25. if ( in_array( 'health_pro', $user->roles, true ) {
  26.   $to = $user_email;
  27.   $subject = "Hi healthpro, welcome to our site!";
  28.   $body = '
  29.            <h1>Dear healthpro,</h1></br>
  30.            <p>Thank you for joining our site. Your account is now active.</p>
  31.            <p>Please go ahead and navigate around your account.</p>
  32.            <p>Let me know if you have further questions, I am here to help.</p>
  33.            <p>Enjoy the rest of your day!</p>
  34.            <p>Kind Regards,</p>
  35.            <p>healthpro</p>
  36.  ';
  37.   $headers = array('Content-Type: text/html; charset=UTF-8');
  38.   if (wp_mail($to, $subject, $body, $headers)) {
  39.     error_log("email has been successfully sent to user whose email is " . $user_email);
  40.   }
  41. }
  42.  
  43. }
  44. add_action('user_register', 'send_welcome_email_to_new_user');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement