简体   繁体   中英

WooCommerce new account email comes with multiple header footer loop

I am importing some users using wp_insert_user function. I am trying to send WooCommerce new account email, when user is successfully imported. It works fine, when there is only one user. But if there are multiple users, the email comes with multiple header and footer loop!

This is what the email looks like, when I am importing four users: 在此处输入图像描述

This is how my code looks like:

foreach ($users as $user) {
    $user_id = wp_insert_user( $userdata[$user] );
    $wc = new WC_Emails();
    $wc->customer_new_account( $user_id, null, true );
}
foreach ($users as $user) {
    $user_id = wp_insert_user( $userdata[$user] );
    global $woocommerce;
    $mailer = $woocommerce->mailer();
    $mailer->customer_new_account( $user_id, null, true );
}

Try like this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM