Hi @waley168
About linking by phone numbers in general:
We don’t have such feature, but if you will do that with custom coding, then have you also implemented some sort of Phone number validation logic? If you haven’t then you shouldn’t implement the linking either, since that way people can enter the phone number of somebody else, and if there is an account with that phone number then you would basically link social media accounts to the WordPress account of somebody else, meaning that you would allow people to abuse the accounts of others.
As for your usecase:
Please note that we can not provide support for custom coding, but I will try to give you some tips that will hopefully help you in achieving your goals.
The first thing that you need to know is that, if you ended up in our registration flow, then it is already a registration action, so you can not link the account to another one, as we will try to create a new account and link the social media account to that. The best, you can do is preventing this registration with an error message, over the “nsl_registration_user_data” filter:
and at the same time link the account to the existing one if you managed to find one.
Your error message should inform the user about what has happened exactly, and if the link was successful, then the next time the person tries to login with social login they would login to the linked WordPress account.
About the linking process:
On the provider instance we have a function that you can call to link a WordPress User ID to a Social Media account:
$provider->linkUserToProviderIdentifier($wordpress_user_id, $socialID);
You can get the $wordpress_user_id from the function parameters of some actions/filters, or if you link the account after the login, then you can get the user ID of the current logged in user e.g. with get_current_user_id() – https://developer.wordpress.org/reference/functions/get_current_user_id/
And you during our flow, you could get the $socialID also from the $provider instance, like:
$provider->getAuthUserData('id');
The ‘nsl_{{provider-id}}_link_user’ filter has a different purpose, and its functuonality is rather connected to the Pro version, that we can not discuss on this forum, as per the forum guidelines:
So if you would like to know more about that, or if you have further questions connected to Pro Addon features, then please get in touch with us rather over the ticket system.
Best regards,
Laszlo.