最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to send Woocommerce Customer Details (Name, Email and Phone Number) to Admin upon signup

programmeradmin2浏览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( '[email protected]', $subject1, $message );
}add_action('user_register', 'so174837_registration_email_alert');

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( '[email protected]', $subject1, $message );
}add_action('user_register', 'so174837_registration_email_alert');
Share Improve this question asked Jan 29, 2020 at 15:45 iPankajSiPankajS 1
Add a comment  | 

1 Answer 1

Reset to default 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! =)

发布评论

评论列表(0)

  1. 暂无评论