Home > Software engineering >  WooCommerce new account email comes with multiple header footer loop
WooCommerce new account email comes with multiple header footer loop

Time:04-06

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: enter image description here

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 );
}

CodePudding user response:

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

  • Related