Minimal plugin that allows WordPress users to log in using Google.
Ultra minimal plugin to let your users login to WordPress applications using their Google accounts. No more remembering hefty passwords!
Create a project from Google Developers Console if none exists.
Go to Credentials tab, then create credential for OAuth client.
YOUR_DOMAIN/wp-login.php
in Authorized redirect URIsThis will give you Client ID and Secret key.
Input these values either in WP Admin > Settings > WP Google Login
, or in wp-config.php
using the following code snippet:
define( 'WP_GOOGLE_LOGIN_CLIENT_ID', 'YOUR_GOOGLE_CLIENT_ID' );
define( 'WP_GOOGLE_LOGIN_SECRET', 'YOUR_SECRET_KEY' );
These browsers are supported. Note, for example, that One Tap Login is not supported in Safari.
You can enable user registration either by
– Enabling Settings > WP Google Login > Enable Google Login Registration
OR
define( 'WP_GOOGLE_LOGIN_USER_REGISTRATION', 'true' );
Note: If the checkbox is ON then, it will register valid Google users even when WordPress default setting, under
Settings > General Settings > Membership > Anyone can register checkbox
is OFF.
By default, when you enable user registration via constant WP_GOOGLE_LOGIN_USER_REGISTRATION
or enable Settings > WP Google Login > Enable Google Login Registration, it will create a user for any Google login (including gmail.com users). If you are planning to use this plugin on a private, internal site, then you may like to restrict user registration to users under a single Google Suite organization. This configuration variable does that.
Add your domain name, without any schema prefix and www,
as the value of WP_GOOGLE_LOGIN_WHITELIST_DOMAINS
constant or in the settings Settings > WP Google Login > Whitelisted Domains
. You can whitelist multiple domains. Please separate domains with commas. See the below example to know how to do it via constants:define( 'WP_GOOGLE_LOGIN_WHITELIST_DOMAINS', 'example.com,sample.com' );
Note: If a user already exists, they will be allowed to login with Google regardless of whether their domain is whitelisted or not. Whitelisting will only prevent users from registering with email addresses from non-whitelisted domains.
For a list of all hooks please refer to this documentation.
WP_GOOGLE_LOGIN_CLIENT_ID
(string): Google client ID of your application.
WP_GOOGLE_LOGIN_SECRET
(string): Secret key of your application
WP_GOOGLE_LOGIN_USER_REGISTRATION
(boolean) (optional): Set true
If you want to enable new user registration. By default, user registration defers to Settings > General Settings > Membership
if constant is not set.
WP_GOOGLE_LOGIN_WHITELIST_DOMAINS
(string) (optional): Domain names, if you want to restrict login with your custom domain. By default, it will allow all domains. You can whitelist multiple domains.
plugin-name.php
to the /wp-content/plugins/
directoryBefore creating a new issue, do browse through the existing issues for resolution or upcoming fixes.
If you still need to log an issue, making sure to include as much detail as you can, including clear steps to reproduce the issue, if possible.
Want to contribute a new feature? Start a conversation by logging an issue.
Once you’re ready to send a pull request, please run through the following checklist:
Browse through the existing issues for anything related to what you want to work on. If you don’t find any related issues, open a new one.
Fork this repository.
Create a branch from develop
for each issue you’d like to address and commit your changes.
Push the code changes from your local clone to your fork.
Open a pull request and that’s it! We’ll respond with feedback as soon as possible (Isn’t collaboration a great thing? 😌)
Once your pull request has passed final code review and tests, it will be merged into develop
and be in the pipeline for the next release. Props to you! 🎉
Clone the plugin from repository.
Run composer install && composer tests:unit
to run unit tests.
[google_login]
with optional attributes: [google_login button_text="Login with Google" force_display="no" redirect_to="https://example.url/page"]
.