Title: Log in with Google
Author: rtCamp
Published: <strong>2020 年 10 月 1 日</strong>
Last modified: 2026 年 2 月 20 日

---

搜索插件

![](https://ps.w.org/login-with-google/assets/banner-772x250.png?rev=3250317)

![](https://ps.w.org/login-with-google/assets/icon-256x256.png?rev=3250317)

# Log in with Google

 作者：[rtCamp](https://profiles.wordpress.org/rtcamp/)

[下载](https://downloads.wordpress.org/plugin/login-with-google.1.4.2.zip)

 * [详情](https://cn.wordpress.org/plugins/login-with-google/#description)
 * [评价](https://cn.wordpress.org/plugins/login-with-google/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/login-with-google/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/login-with-google/#developers)

 [支持](https://wordpress.org/support/plugin/login-with-google/)

## 描述

Ultra minimal plugin to let your users login to WordPress applications using their
Google accounts. No more remembering hefty passwords!

### Initial Setup

 1. Create a project from [Google Developers Console](https://console.developers.google.com/apis/dashboard)
    if none exists.
 2. Go to **Credentials** tab, then create credential for OAuth client.
 3.  * Application type will be **Web Application**
     * Add `YOUR_DOMAIN/wp-login.php` in **Authorized redirect URIs**
 4. This will give you **Client ID** and **Secret key**.
 5. Input these values either in `WP Admin > Settings > WP Google Login`, or in `wp-
    config.php` using the following code snippet:
 6. `define( 'WP_GOOGLE_LOGIN_CLIENT_ID', 'YOUR_GOOGLE_CLIENT_ID' );
     define( 'WP_GOOGLE_LOGIN_SECRET','
    YOUR_SECRET_KEY' );

### Browser support

[These browsers are supported](https://developers.google.com/identity/gsi/web/guides/supported-browsers).
Note, for example, that One Tap Login is not supported in Safari.

### How to enable automatic user registration

You can enable user registration either by
 – Enabling _Settings > WP Google Login
> Enable Google Login Registration_

OR

 * Adding
    `define( 'WP_GOOGLE_LOGIN_USER_REGISTRATION', 'true' );` in wp-config.
   php file.

**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.

### Restrict user registration to one or more domain(s)

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.

### Hooks

For a list of all hooks please refer to [this documentation](https://github.com/rtCamp/login-with-google#hooks).

#### wp-config.php parameters list

 * `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.

### BTW, We’re Hiring!

## 屏幕截图

 * [[
 * Login screen with Google option added.
 * [[
 * Plugin settings screen.
 * [[
 * Settings within Google Developer Console.

## 区块

该插件提供了 1 个区块.

 *   Log in with Google Login with Google button block.

## 安装

 1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Follow “Setup” instructions in ReadMe to configure credentials from Google Developers
    Console.

## 常见问题

### Reporting a bug 🐞

Before creating a new issue, do browse through the [existing issues](https://github.com/rtCamp/login-with-google/issues)
for resolution or upcoming fixes.

If you still need to [log an issue](https://github.com/rtCamp/login-with-google/issues/new),
making sure to include as much detail as you can, including clear steps to reproduce
the issue, if possible.

### Creating a pull request

Want to contribute a new feature? Start a conversation by [logging an issue](https://github.com/rtCamp/login-with-google/issues).

Once you’re ready to send a pull request, please run through the following checklist:

 1. Browse through the [existing issues](https://github.com/rtCamp/login-with-google/issues)
    for anything related to what you want to work on. If you don’t find any related
    issues, open a new one.
 2. Fork this repository.
 3. Create a branch from `develop` for each issue you’d like to address and commit 
    your changes.
 4. Push the code changes from your local clone to your fork.
 5. Open a pull request and that’s it! We’ll respond with feedback as soon as possible(
    Isn’t collaboration a great thing? 😌)
 6. 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! 🎉

### Unit testing

 * Clone the plugin from [repository](https://github.com/rtCamp/login-with-google).
 * Run `composer install && composer tests:unit` to run unit tests.

### Code Snippets

Code snippets to extend and customize the plugin can be found [here](https://github.com/rtCamp/login-with-google/blob/develop/docs/CODE_SNIPPETS.md).

## 评价

![](https://secure.gravatar.com/avatar/3e48554a4635c0561806b34bee31eaa35622f71a173555b530bc1bdcc31d2960?
s=60&d=retro&r=g)

### 󠀁[Excellent plugin](https://wordpress.org/support/topic/excellent-plugin-9787/)󠁿

 [nimonogi](https://profiles.wordpress.org/nimonogi/) 2026 年 1 月 16 日

Works as advertised, SImple and easy to use.

![](https://secure.gravatar.com/avatar/d72add6b21889fb6373922dd04eefb8c29f36800115e7298d18cc103a88d46d8?
s=60&d=retro&r=g)

### 󠀁[Minimal and Best](https://wordpress.org/support/topic/minimal-and-best-2/)󠁿

 [Menn](https://profiles.wordpress.org/mennstudio/) 2024 年 10 月 21 日

For multiple social login accounts, I prefer Nextend Social Login and Register. 
But for internal web or website that has only admin team, no users, I think this
plugin is the best.

![](https://secure.gravatar.com/avatar/515b062daacee82ada2b267dad0f53162e7a3cd44576d88ed382fff3261e58b3?
s=60&d=retro&r=g)

### 󠀁[Does not work in multisite](https://wordpress.org/support/topic/does-not-work-in-multisite-7/)󠁿

 [marcelowins](https://profiles.wordpress.org/marcelowins/) 2024 年 7 月 5 日

works fine for one site but not for multisite, need to add a notice about it

![](https://secure.gravatar.com/avatar/7b3bd83d9e1e29a7a296c984cd922f8202c3107783ed11261b663e59fbb033a1?
s=60&d=retro&r=g)

### 󠀁[Fantastic, has bug](https://wordpress.org/support/topic/fantastic-has-bug/)󠁿

 [rothschild86](https://profiles.wordpress.org/rothschild86/) 2024 年 5 月 12 日
2 回复

As of writing, will register a new user regardless of this setting, which prevents
me from using it at the moment:Enable Google Login Registration

![](https://secure.gravatar.com/avatar/ac86dd062a70cfbe5553e9705a5ed11516e47f61f85dc31cb99e688792fdc5e7?
s=60&d=retro&r=g)

### 󠀁[Very nice plugin](https://wordpress.org/support/topic/very-nice-plugin-1017/)󠁿

 [dvamvourellis](https://profiles.wordpress.org/19db/) 2023 年 4 月 24 日

Works as expected but the important part is that is customization friendly (ex. 
shortcodes) and easy to set up. Thank you

![](https://secure.gravatar.com/avatar/2139adb84d3250a1f1931b3ae540c3493f655ce678f99edb6096d4402844bce4?
s=60&d=retro&r=g)

### 󠀁[Best plugin for login with Google](https://wordpress.org/support/topic/best-plugin-for-login-with-google/)󠁿

 [fakem1ner](https://profiles.wordpress.org/fakem1ner/) 2022 年 5 月 30 日

Half of the plug-ins simply do not work, the other can be configured only when the
pigs fly. But this plugin is configured in just a couple of clicks and works stably.
And just because it is one of the few workers I am writing this and rate with 5 
stars

 [ 阅读所有15条评价 ](https://wordpress.org/support/plugin/login-with-google/reviews/)

## 贡献者及开发者

「Log in with Google」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ rtCamp ](https://profiles.wordpress.org/rtcamp/)
 *   [ Shalin Shah ](https://profiles.wordpress.org/sh4lin/)
 *   [ Nikhil Joshua ](https://profiles.wordpress.org/nikhiljoshua/)
 *   [ Chirag Mathur ](https://profiles.wordpress.org/mchirag2002/)
 *   [ Sagar Tamang ](https://profiles.wordpress.org/mi5t4n/)

「Log in with Google」插件已被翻译至 5 种本地化语言。 感谢[所有译者](https://translate.wordpress.org/projects/wp-plugins/login-with-google/contributors)
为本插件所做的贡献。

[帮助将「Log in with Google」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/login-with-google)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/login-with-google/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/login-with-google/)，或通过[RSS](https://plugins.trac.wordpress.org/log/login-with-google/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/login-with-google/)。

## 更新日志

#### 1.4.2

Fix: Migrated rtcamp.google_redirect_url from action to filter.
 Chore: Documentation
update.

#### 1.4.1

Fix: Resolved the issue of redirect_to parameters not working with the shortcode.

Update: Migrated block implementation to modern block implementations. Update: Updated
Composer and NPM dependencies. Fix: Fixed the issue of One-tap script not being 
enqueued if the user was logged out. Chore: Documentation update.

#### 1.4.0

Update: Migrated One Tap Login to use FedCM.
 Update: After a successful login or
logout, users are now redirected to the page they originally intended to access.
Update: When the plugin performs a redirect, it now includes an x-redirect-by header.
Update: A settings page link has been added directly under the plugin name on the
Plugins screen. Fix: Resolved an issue with generating unique usernames. Fix: Fixed
a bug where JavaScript string translations were not being applied correctly. Chore:
Documentation update.

#### 1.3.7

 * Compatible with WordPress 6.7.2

#### 1.3.6

 * Fix: PHPCS Errors and Warnings

#### 1.3.5

 * Fix: FILTER_SANITIZE_STRING Deprecation warning

#### 1.3.4

 * Chore: Doc update

#### 1.3.3

 * Fix: Redirection back to login page issue.

#### 1.3.2

 * Compatible with PHP 8.1
 * Compatible with WordPress latest version 6.3.1

#### 1.3.1

 * Maintenance release: Updated minimum requirements.

#### 1.3.0

 * Feature: Gutenberg block for Login button.
 * Feature: Save user first name and last name on registration.
 * Add: PHP 8.0 compatibility.
 * Add: Added hook after user authentication.
 * Add: Added hook after user is logged-in.
 * Fix: set login cookie with shortcode display.
 * Fix: Redirection back to login page issue.
 * Updated npm packages and laravel-mix.

#### 1.2.2

 * Maintenance release. Requires PHP >= 7.4.

#### 1.2.1

 * Feature: Provide filter for client arguments: rtcamp.google_client_args

#### 1.2

 * Feature: One-Tap Login setting for supported browsers.

#### 1.1

 * Feature: Add shortcode `[google_login]` with optional attributes: `[google_login
   button_text="Login with Google" force_display="no" redirect_to="https://example.
   url/page"]`.
 * Feature: Replace third-party oAuth client with custom GoogleClient class.
 * Fix: Identification of state value, whether a given oAuth login is relevant to
   this plugin.
 * Remove: Google oAuth library from composer.

#### 1.0.14

 * Revert Login with GitHub state fix.

#### 1.0.13

 * Fix login issue related to oAuth state.

#### 1.0.12

 * Fix conflict with Login with GitHub plugin.

#### 1.0.11

 * Add ‘login_with_google/client_arguments’ filter for Google_Client arguments.

#### 1.0.10

 * Fix issue where JS/CSS were not loading.

#### 1.0.9

 * Initial release.

#### 1.3.1

 * Maintenance release: Updated minimum requirements.

## 额外信息

 *  版本 **1.4.2**
 *  最后更新：**2 月前**
 *  活跃安装数量 **6,000+**
 *  WordPress 版本 ** 5.5 或更高版本 **
 *  已测试的最高版本为 **6.7.5**
 *  PHP 版本 ** 7.4 或更高版本 **
 *  语言
 * [Chinese (China)](https://cn.wordpress.org/plugins/login-with-google/) 、 [Chinese (Taiwan)](https://tw.wordpress.org/plugins/login-with-google/)、
   [English (US)](https://wordpress.org/plugins/login-with-google/) 、 [Georgian](https://ka.wordpress.org/plugins/login-with-google/)、
   [Swedish](https://sv.wordpress.org/plugins/login-with-google/) 和 [Ukrainian](https://uk.wordpress.org/plugins/login-with-google/).
 *  [翻译成简体中文](https://translate.wordpress.org/projects/wp-plugins/login-with-google)
 * 标签
 * [authentication](https://cn.wordpress.org/plugins/tags/authentication/)[Google Login](https://cn.wordpress.org/plugins/tags/google-login/)
   [oauth](https://cn.wordpress.org/plugins/tags/oauth/)[sign in](https://cn.wordpress.org/plugins/tags/sign-in/)
   [sso](https://cn.wordpress.org/plugins/tags/sso/)
 *  [高级视图](https://cn.wordpress.org/plugins/login-with-google/advanced/)

## 评级

 4.5 星（最高 5 星）。

 *  [  12 条 5 星评价     ](https://wordpress.org/support/plugin/login-with-google/reviews/?filter=5)
 *  [  1 条 4 星评价     ](https://wordpress.org/support/plugin/login-with-google/reviews/?filter=4)
 *  [  1 条 3 星评价     ](https://wordpress.org/support/plugin/login-with-google/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/login-with-google/reviews/?filter=2)
 *  [  1 条 1 星评价     ](https://wordpress.org/support/plugin/login-with-google/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/login-with-google/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/login-with-google/reviews/)

## 贡献者

 *   [ rtCamp ](https://profiles.wordpress.org/rtcamp/)
 *   [ Shalin Shah ](https://profiles.wordpress.org/sh4lin/)
 *   [ Nikhil Joshua ](https://profiles.wordpress.org/nikhiljoshua/)
 *   [ Chirag Mathur ](https://profiles.wordpress.org/mchirag2002/)
 *   [ Sagar Tamang ](https://profiles.wordpress.org/mi5t4n/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/login-with-google/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](https://rtcamp.com/)