Woocommerce New Customer Admin Notification Email

I am building an ecommerce site using WordPress and Woocommerce. I need the site to send out a notification email to the site administrator when a new customer account is registered. I thought this functionality would be built into Woocommerce since it uses the WordPress user account structure and WordPress sends new user notifications, but it doesn’t appear to be. Does anyone know of a plugin or a function I can use to add this functionality? Thanks!

Related posts

Leave a Reply

5 comments

  1. I’m assuming that you are using html inside emails. If you are using plain text the procedure is similar.

    You need to override the woocommerce template structure. Here you can find how: http://docs.woothemes.com/document/template-structure/.

    Actually the only file you need to override is your_template_directory/woocommerce/emails/customer-new-account.php.

    At the end of this file add this line of code:

    <?php do_action( 'new_customer_registered', $user_login ); ?>
    

    In functions.php add this:

    function new_customer_registered_send_email_admin($user_login) {
      ob_start();
      do_action('woocommerce_email_header', 'New customer registered');
      $email_header = ob_get_clean();
      ob_start();
      do_action('woocommerce_email_footer');
      $email_footer = ob_get_clean();
    
      woocommerce_mail(
        get_bloginfo('admin_email'),
        get_bloginfo('name').' - New customer registered',
        $email_header.'<p>The user '.esc_html( $user_login ).' is registered to the website</p>'.$email_footer
      );
    }
    add_action('new_customer_registered', 'new_customer_registered_send_email_admin');
    
  2. add_action('woocommerce_created_customer', 'admin_email_on_registration', 10 , 1);
    function admin_email_on_registration( $customer_id) {
        wp_new_user_notification( $customer_id );
    }
    

    woocommerce_created_customer is hook which is called when user created by woocommerce. It only sends notification to customer. we will use wp_new_user_notification() function to send notification to Admin.

  3. I was pulling my hair out trying to figure this same issue out and after going back and forth with the developers the default is to not send new customer registration notification emails to admin.

    After trying various email plugins and even resorting to using WP SMTP Email, I finally decided to leave it alone.

    That said, WooCommerce 2.0 was released today so it may be built in the new version.