Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function send_welcome_email_to_new_user($user_id) {
- $user = get_userdata($user_id);
- $user_email = $user->user_email;
- // email will send only for "health_pro" registers
- if ( in_array( 'customer', $user->roles, true ) {
- $to = $user_email;
- $subject = "Hi customer, welcome to our site!";
- $body = '
- <h1>Dear customer,</h1></br>
- <p>Thank you for joining our site. Your account is now active.</p>
- <p>Please go ahead and navigate around your account.</p>
- <p>Let me know if you have further questions, I am here to help.</p>
- <p>Enjoy the rest of your day!</p>
- <p>Kind Regards,</p>
- <p>customer</p>
- ';
- $headers = array('Content-Type: text/html; charset=UTF-8');
- if (wp_mail($to, $subject, $body, $headers)) {
- error_log("email has been successfully sent to user whose email is " . $user_email);
- }
- }
- // email will send only for "health_pro" registers
- if ( in_array( 'health_pro', $user->roles, true ) {
- $to = $user_email;
- $subject = "Hi healthpro, welcome to our site!";
- $body = '
- <h1>Dear healthpro,</h1></br>
- <p>Thank you for joining our site. Your account is now active.</p>
- <p>Please go ahead and navigate around your account.</p>
- <p>Let me know if you have further questions, I am here to help.</p>
- <p>Enjoy the rest of your day!</p>
- <p>Kind Regards,</p>
- <p>healthpro</p>
- ';
- $headers = array('Content-Type: text/html; charset=UTF-8');
- if (wp_mail($to, $subject, $body, $headers)) {
- error_log("email has been successfully sent to user whose email is " . $user_email);
- }
- }
- }
- add_action('user_register', 'send_welcome_email_to_new_user');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement