тнє Sufi
тнє Sufi

Reputation: 634

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

Upvotes: 2

Views: 216

Answers (1)

mujuonly
mujuonly

Reputation: 11861

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

Upvotes: 2

Related Questions