Last active
July 9, 2020 09:55
-
-
Save mt8/dab1465dec701b6112b308076e892bc7 to your computer and use it in GitHub Desktop.
[WordPress] #WordPress の #Auth0 プラグインで、Twitter認証したときにプロフィール名がカタカナだとWordPressユーザー作成に失敗してログインできない問題を回避する
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
<?php | |
add_filter( 'auth0_create_user_data', 'my_auth0_create_user_data' , 10, 2 ); | |
function my_auth0_create_user_data( $user_data, $userinfo ) | |
{ | |
if ( ! is_null( $userinfo ) && is_object( $userinfo ) ) { | |
$identities = property_exists( $userinfo, 'identities' ) ? $userinfo->identities : []; | |
if ( is_array( $identities ) && ! empty( $identities ) ) { | |
$identitiy = $identities[0]; | |
if ( ! is_null( $identitiy ) && is_object( $identitiy ) ) { | |
$provider = property_exists( $identitiy, 'provider' ) ? $identitiy->provider : ''; | |
if ( 'twitter' == $provider ) { | |
//twitterのアカウント名@exampleをWordPressユーザー名にする | |
$user_data['user_login'] = $userinfo->screen_name; | |
} | |
} | |
} | |
} | |
return $user_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment