-
-
Save boonebgorges/f2ad42d0f741c2a075e7d2c0d80f504d to your computer and use it in GitHub Desktop.
Force wp-cassify to match on user_email
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( | |
'wp_cassify_custom_parsing_cas_xml_response', | |
function( $response, $user_data ) { | |
// If a user already exists by this cas_user_id, no need to continue. | |
if ( username_exists( $user_data['cas_user_id'] ) ) { | |
return $user_data; | |
} | |
// If there's an email match, override the cas_user_id. | |
$email_match_user = get_user_by( 'email', $user_data['email'] ); | |
if ( $email_match_user ) { | |
$user_data['cas_user_id'] = $email_match_user->user_login; | |
} | |
return $user_data; | |
}, | |
10, | |
2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment