login-with-google
login-with-google copied to clipboard
Prevent wp_user creation
I'm using the rtcamp.google_user_authenticated hook for custom login permission checks. After a successful check, I map the google login to a specific generic user (BGuest) with the following code:
$user = get_user_by('login', 'BGuest');
wp_set_current_user($user->ID);
wp_set_auth_cookie($user->ID);
do_action('wp_login', $user->user_login, $user);
The login mapping works perfectly, and the user is logged in as BGuest. However, WordPress still creates a new user using the Google account details.
I've noticed that I need to set WP_GOOGLE_LOGIN_USER_REGISTRATION = true in order to pass the first login screen. If this is set to false, I cannot proceed with the login.
Is there a hook or another way to prevent WordPress from creating new users while still allowing the login process to proceed?
Any help would be greatly appreciated! Thanks, Ravid