Hello,
With the caveat that this is fairly new code, so that you may want to test this thoroughly:
The first time you login in with Vipps now, a link is created using the Vipps credentials and the user. This means that the email address is only used to find the user the first time. The email is used here because it is a) unique in WP, b) verified in Vipps and c) used in WP to handle stuff like password recovery and so forth.
Keeping in mind that phone numbers etc are *not* unique in the WP database, you can now change the mechanism that finds an existing user in the database using the following filter:
$user = apply_filters( 'login_with_vipps_authenticate_user', $user, $userinfo, $session);
– if $user is nonempty here, the user will either have logged in before or have a user with the email address corresponding to the verified email address in Vipps.
If $user is nil, you can then find the user using the $userinfo (from Vipps) – you will find the keys ‘phone_number’ and ’email’ here. You can then search the User database for a user with the given meta values. If you find *two* users with the same phone number, the handling will depend on your application.