Plugin Author
Claude
(@claudeschlesser)
Hello,
WooCommerce probably saves the first and lastname in custom fields that Social Login is not aware of.
What you could try is a hook like this:
http://docs.oneall.com/plugins/guide/social-login-wordpress/#3b
The example is for BuddyPress, but for WooCommerce it should be similar.
xprofile_set_field_data ('First Name', $user_data->ID, $identity->name->givenName);
xprofile_set_field_data ('Last Name', $user_data->ID, $identity->name->familyName);
In these values you have the data:
$identity->name->givenName
$identity->name->familyName
You then need to replace xprofile_set_field_data by the function that saves the data for WooCommerce.
Do not hesitate to write another post if you are stuck, I will then have a closer look.
Regards,
-
This reply was modified 5 years, 3 months ago by
Claude.
-
This reply was modified 5 years, 3 months ago by
Claude.
Did you ever find a WooCommerce solution for this. Is there a hook to use to populate those pages when you login with this SSO service?
Try putting this in your 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);
update_user_meta ($user_data->id, ‘billing_last_name’, $identity->name->familyName);
}
//Set custom roles for new users
function oa_social_login_set_new_user_role ($user_role)
{
//This is an example for a custom setting with one role
$user_role = ‘customer’;
//The new user will be created with this role
return $user_role;
}
//This filter is applied to the roles of new users
add_filter(‘oa_social_login_filter_new_user_role’, ‘oa_social_login_set_new_user_role’);
Awesome. Thanks so much for sharing!