2

I've created a sign up page for new customers to create an account.

This is working fine but I would like to hook into WooCommerce customer_new_account inside WooCommerce/Classes/Emails/class-wc-emails.php to send the welcome email.

Is there an existing hook I can use or what's the best way to do this.

I don't want to create another welcome email function.

Thanks.

Answer

do_action('woocommerce_created_customer', $user_id, $new_customer_data, false);
1
  • I voted up, Your answer helped me... Jan 12, 2016 at 10:03

1 Answer 1

3

There is no actions/filters to hook to. You need to override standard WC_Email_Customer_New_Account class and implement your own logic. To do it you need to create your own class which will inherit that class and register it.

class WPSE8170_Email_Customer_New_Account extends WC_Email_Customer_New_Account {

    function trigger( $user_id, $user_pass = '', $password_generated = false ) {
        // do what you need here and then call parent method
        parent::trigger( $user_id, $user_pass, $password_generated );
    }

}

Now you need to register this class:

add_filter( 'woocommerce_email_classes', 'wpse8170_update_email_classes' );
function wpse8170_update_email_classes( $emails ) {
    $emails['WC_Email_Customer_New_Account'] = new WPSE8170_Email_Customer_New_Account();
    return $emails;
}
2
  • Thanks but I just found it do_action('woocommerce_created_customer', $user_id, $new_customer_data, false);
    – user742736
    Jul 3, 2014 at 5:58
  • it was a bit unclear what exactly you needed Jul 3, 2014 at 6:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.