0

I am trying to send a custom email to the admin account when any user registers through WooCommerce. I have managed to get it to send the username ($user_login) but have been unsuccessful in managing to provide the admin with info such as customer email and names. Is there anything obvious I'm missing?

This is at the bottom of my custom customer-new-account.php file:

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

This is then in my functions.php:

//email admin on new customer sign up
function new_customer_registered_send_email_admin($user_login, $user_email) {
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 ).' created an account on the website.<br>Email:'.esc_html( $user_email ).'</p>'.$email_footer
);
}
add_action('new_customer_registered', 'new_customer_registered_send_email_admin');
1

Yes, the action needs to specify two parameters.

add_action('new_customer_registered', 'new_customer_registered_send_email_admin', 10, 2);

Apart from that I can't see any other issues...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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