Skip to content

Instantly share code, notes, and snippets.

@boonebgorges
Created February 3, 2022 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boonebgorges/f2ad42d0f741c2a075e7d2c0d80f504d to your computer and use it in GitHub Desktop.
Save boonebgorges/f2ad42d0f741c2a075e7d2c0d80f504d to your computer and use it in GitHub Desktop.
Force wp-cassify to match on user_email
<?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