Created
November 15, 2022 15:47
-
-
Save pdewouters/c500d010b2753a8b37a7a62a0b95ea9d to your computer and use it in GitHub Desktop.
vipps phone login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'login_with_vipps_authenticate_user', [ $this, 'maybe_auth_winorg_phone' ], 10, 3 ); | |
public function maybe_auth_winorg_phone( $user, array $userinfo, \VippsSession $session ) { | |
if ( $user instanceof \WP_User ) { | |
return $user; | |
} | |
// phpcs:enable NeutronStandard.Functions.TypeHint.NoArgumentType, NeutronStandard.Functions.TypeHint.NoReturnType | |
$args = [ | |
'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query | |
[ | |
'key' => 'Phone', | |
'value' => substr( $userinfo['phone_number'], 2 ), | |
'compare' => '=', | |
], | |
], | |
]; | |
$users = get_users( $args ); | |
return ! empty( $users ) && ( $users[0] instanceof \WP_User ) ? $users[0] : $user; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment