Map Fields (First Name, Last Name, Email address) with WooCommerce Billing Details

Hi Team,

I am using One All social login on a Woocommerce website.

After a user logs in / registers, is it possible to automatically map the following fields? The reasons is because, currently, even if the user logs in / registers via social profile, he has to manually enter the first name and last name on the billing page.

First Name ---> First Name (Customer Billing Address)
Last Name ---> Last Name (Customer Billing Address)
Email (Contact Info) ---> Email (Customer Billing Address)

Thanks in advance.

Regards

Answers

  • Hi,
    To fill the billing address when someone registers with social login, you can add the following hook into your theme's functions.php:
    //This action is called whenever Social Login adds a new user add_action ('oa_social_login_action_after_user_insert', 'oa_social_login_store_extended_data', 10, 2); function oa_social_login_store_extended_data ($user_data, $identity) { error_log (print_r ($identity, true)); // to get all fields. //Example to store the billing first name: update_user_meta ($user_data->id, 'billing_first_name', $identity->name->givenName); }
    However, the normal user registration does not seem to fill those billing fields either.
    So, perhaps this hook should be applied to all registrations? (which is a different event and code).
    Thanks.
  • Would it be possible to have the code to do the same for the surname? I can't make it work..
  • Few years late. But just in case anyone else is looking this adds both first and last name:

    //This action is called whenever Social Login adds a new user
    add_action ('oa_social_login_action_after_user_insert', 'oa_social_login_store_extended_data', 10, 2);
    function oa_social_login_store_extended_data ($user_data, $identity)
    {
    error_log (print_r ($identity, true)); // to get all fields.
    //Example to store the billing first name:
    update_user_meta ($user_data->id, 'billing_first_name', $identity->name->givenName);
    update_user_meta ($user_data->id, 'billing_last_name', $identity->name->familyName);
    }

Welcome!

Please sign in to your OneAll account to ask a new question or to contribute to the discussions.

Please click on the link below to connect to the forum with your OneAll account.