hm ok, so effectively
- There would be a subset of your users with different emails on wordpress and discourse.
- Your username is gauranteed to be the same as its provided by your identity provider for both wordpress and discourse
If we were to decouple the WP Discourse user webhook from the DiscourseConnect functionality (possible), then user matching would occur on the basis of email, not username. Your situation is somewhat specific to your identity setup.
I think this case that’s better handled via custom code on your wordpress. What you want is something like this:
function update_discourse_username( $user_login, $user ) {
update_user_meta( $user->ID, 'discourse_username', $user_login );
}
add_action( 'wp_login', 'update_discourse_username', 10, 2);
Basically, just assign the discourse_username
meta field as the WP username after login, as they’re guaranteed to be the same. Note that “user_login” is what the “username” is sometimes called in wordpress code.