RTFM

Google Login for Existing Users

Google Login for Existing Users
Current Version
1.1.0
Requires WordPress
6.0
Tested Up To
7.0
Translations included
🇺🇸 English
🇪🇸 Spanish
🇫🇷 French
🇩🇪 German
🇨🇳 Chinese
🇯🇵 Japanese

Overview

Google Login for Existing Users lets people sign in with Google when their Google email address matches an existing WordPress user account on your site.

This plugin does not create new user accounts. It only signs in users who already exist in WordPress.

How It Works

When a visitor clicks the Google login button:

  1. They are sent to Google to approve sign-in.
  2. Google returns them to your WordPress login URL.
  3. The plugin checks the Google account email address.
  4. If that email address matches an existing WordPress user account, the user is signed in.

If there is no matching WordPress account, login is denied.

Requirements

  • WordPress with standard login access available at wp-login.php
  • A Google Cloud project with an OAuth client ID and client secret
  • Existing WordPress user accounts with email addresses that match the users’ Google accounts

Installation

  1. Upload the plugin to your WordPress site.
  2. Activate the plugin from the WordPress admin area.
  3. Go to Settings > Google Login.
  4. Add your Google Client ID and Google Client Secret.
  5. Save your settings.

Google OAuth Setup

You must create a Google OAuth application before the plugin can work.

In WordPress

Open Settings > Google Login and copy the value shown in:

  • Authorized Redirect URI

This exact URL must be added to your Google OAuth client.

In Google Cloud

Create or open a Google Cloud project and configure an OAuth client. Add the redirect URI from the plugin settings page to the list of authorized redirect URIs for that client.

Then copy these values back into WordPress:

  • Google Client ID
  • Google Client Secret

Save the settings in WordPress after pasting both values.

Plugin Settings

The plugin adds one settings page:

  • Settings > Google Login

Available fields:

  • Google Client ID: Your OAuth client ID from Google Cloud.
  • Google Client Secret: The matching OAuth client secret.
  • Authorized Redirect URI: The exact callback URL you must register with Google.

Usage

Default WordPress Login Screen

Once the plugin is configured, it automatically adds a Log in with Google button to the standard WordPress login screen.

If the plugin has not been configured with both the client ID and client secret, the Google login button will not appear.

Shortcode

You can place the Google login button anywhere shortcodes are supported with:

[gleu_login_link]

Behavior:

  • Logged-out visitors see the Google login button.
  • Logged-in users see a logout link instead.
  • If the plugin is not configured yet, nothing is displayed.

Block Editor

The plugin also includes a block named:

  • Google Login Link

Add this block in the block editor to display the same login button used by the shortcode.

Login Rules

The plugin only signs in a user when all of the following are true:

  • The Google sign-in completes successfully.
  • The Google account has a verified email address.
  • A WordPress user already exists with the same email address.

The plugin does not:

  • create new user accounts
  • merge accounts
  • link multiple email addresses to one account
  • bypass normal WordPress login permissions

Security Notes

  • The plugin uses a temporary OAuth state token to protect the login flow.
  • OAuth state tokens expire automatically after 15 minutes.
  • Only verified Google email addresses are accepted.
  • Users are signed in through the normal WordPress authentication flow.

Troubleshooting

The Google login button does not appear

Check the following:

  • The plugin is activated.
  • Both the Google Client ID and Google Client Secret are saved.
  • You are viewing the standard WordPress login page or a page that includes the shortcode or block.

Google returns an error after sign-in

Common causes:

  • The redirect URI in Google Cloud does not exactly match the URI shown in the plugin settings.
  • The client ID and client secret do not belong to the same Google OAuth application.
  • The OAuth credentials were copied with extra spaces or incomplete values.

A user can authenticate with Google but still cannot sign in

This usually means one of the following:

  • The Google account email address is not verified.
  • No existing WordPress user account matches that Google email address.

The user is sent back to the login page with an error

The plugin can return users to the login screen if:

  • the Google sign-in session expired
  • the OAuth token request failed
  • Google user details could not be retrieved
  • the email address was not verified
  • there is no matching WordPress user account

Frequently Asked Questions

Does this plugin create new users automatically?

No. It only signs in users who already have a WordPress account.

Can I use this on a custom login page?

Yes. Use the [gleu_login_link] shortcode or the Google Login Link block on the page where you want the button to appear.

What happens if a user is already logged in?

The shortcode and block output a logout link instead of the Google login button.

Does the plugin replace the normal WordPress login form?

No. It adds a Google login option alongside your existing WordPress login experience.

Developers

This plugin does not currently register any custom plugin-specific action hooks or filter hooks for third-party developers.

It does, however, complete login using the normal WordPress login flow. That means standard WordPress login hooks can be used to customize what happens after a successful Google sign-in.

wp_login

The plugin fires WordPress’s standard wp_login action after the matched user is authenticated.

Use this when you want to run custom code immediately after a successful Google login.

Example:

<?php
add_action(
    'wp_login',
    function ( $user_login, $user ) {
        if ( ! $user instanceof WP_User ) {
            return;
        }

        update_user_meta( $user->ID, 'last_google_login_notice', current_time( 'mysql' ) );
    },
    10,
    2
);

login_redirect

The plugin applies WordPress’s standard login_redirect filter before sending the user to their destination after login. By default, the plugin uses the WordPress admin URL.

Use this when you want to send successful Google logins somewhere other than the admin dashboard.

Example:

<?php
add_filter(
    'login_redirect',
    function ( $redirect_to, $requested_redirect_to, $user ) {
        if ( $user instanceof WP_User ) {
            return home_url( '/member-dashboard/' );
        }

        return $redirect_to;
    },
    10,
    3
);

Support Notes

If you change your site’s login URL behavior, domain, or protocol, review the redirect URI in Settings > Google Login and update the Google OAuth client if needed.