wp mail - Unable to send custom welcome email after user register

I am trying to send a custom welcome email after user register on our website. The default role set is 'subscriber&

I am trying to send a custom welcome email after user register on our website. The default role set is 'subscriber'. The email should pull some user meta values and display the same in the email.

I tried the following function but somehow the email does not get delivered or even if delivered, the meta values do not show up. I put the function in my child theme's functions.php file. Any help will be highly appreciated.

function user_role_update_new($user_id, $role)
{
    if ($role == 'subscriber') {
        $user_info = get_userdata($user_id);
        $name      = $user_info->display_name;
        $appid     = get_user_meta($user_id, 'student_id', true);
        $class     = get_user_meta($user_id, 'class_admission', true);
        $stream    = get_stream_in_text($user_id);
        $session   = get_current_sesssion();

        $to        = $user_info->user_email;
        $subject   = 'Your Application for ' . $class . ' has been received';
        $message   = '<div style="text-align: center; font-weight: 600; font-size: 26px;"><strong>Tarabhusan Pal Junior Science College</strong></div><div style="clear: both;">Dear <strong>' . $name . '</strong> (' . $appid . '),</div>
        <div style="padding: 30px 0;">You have successfully applied for Admission into '. $class . '( ' . $stream . ' ) Class for the session ' . $session . '.<p>Your application is under process and will be sorted out maximum within 2 working days for further follow-up from your end.</p></div><div style="color: #999;"><p>Thanking you,</p><p>Tarabhusan Pal Junior Science College<br /> Karimganj</p></div>';
        wp_mail($to, $subject, $message);
    }
}
add_action('user_register', 'user_role_update_new', 10, 2);

add_filter('wp_mail_from', 'email_from_address');
function email_from_address($email)
{
    return "[email protected]";
}

add_filter('wp_mail_from_name', 'email_from_name');
function email_from_name($name)
{
    return "Online Student Admission - Tarabhusan Pal Junior Science College";
}

function email_from_content_type()
{
    return "text/html";
}
add_filter('wp_mail_content_type', 'email_from_content_type');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742386195a4434107.html

相关推荐

  • wp mail - Unable to send custom welcome email after user register

    I am trying to send a custom welcome email after user register on our website. The default role set is 'subscriber&

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信