0

Use case:
I want to send an email notification to the admin or the sales staff whenever someone signup as customer on my Woocommerce Shop.

Details I want to include: Name, Phone Number, Email Address.

I'm already taking phone number while registration as billing_phone

Issue
The snippet mentioned below sends email address only. Not the NAME or the Phone Number.


I want send the Phone number, email and name to the any given email of the staff. Can you help me with this?

    function so174837_registration_email_alert( $user_id ) {
    $user    = get_userdata( $user_id );
    $email   = $user->user_email;
      $name   = $user->user_email;
    $phone = get_user_meta( $customer_id, 'billing_phone', true );
    $message = $name.''.$email .' - ' .$phone. 'has registered to your website.';
    $subject1= $name. ' - '.$phone .'just signed up. Call him.';
    wp_mail( 'xxy@gmail.com', $subject1, $message );
}add_action('user_register', 'so174837_registration_email_alert');
0

Try changing this: $name = $user->user_email; to this:

$name = $user->first_name;

And this: $phone = get_user_meta( $customer_id, 'billing_phone', true ); to this:

$phone = get_user_meta( $user_id, 'billing_phone', true );

Did it work for you? Let me know! =)

| improve this answer | |
  • Thanks for answering this but it did not work. I just tested it. – iPankajS Jan 31 at 3:10

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.