[WordPress] 外掛分享: Log in with Google

首頁外掛目錄 › Log in with Google
WordPress 外掛 Log in with Google 的封面圖片
6,000+
安裝啟用
★★★★
4.5/5 分(15 則評價)
35 天前
最後更新
0%
問題解決
WordPress 5.5+ PHP 7.4+ v1.4.2 上架:2020-09-30

內容簡介

這是一個極簡化的外掛,讓您的使用者可以使用他們的 Google 帳戶登入 WordPress 應用程式,不再需要記住笨重的密碼!

初始設置

如果尚未存在,請從 Google 開發者控制台 建立一個項目。

前往憑證頁面,然後為 OAuth 用戶端建立憑證。

應用程式類型將為 Web 應用程式
在授權重新導向 URI 中添加 YOUR_DOMAIN/wp-login.php

這將為您提供客戶端 ID 和秘密金鑰。

將這些值輸入到 WP 管理員 > 設置 > WP Google 登入 或使用以下代碼片段在 wp-config.php 中輸入:

define( 'WP_GOOGLE_LOGIN_CLIENT_ID', 'YOUR_GOOGLE_CLIENT_ID' );
define( 'WP_GOOGLE_LOGIN_SECRET', 'YOUR_SECRET_KEY' );

瀏覽器支援

這些瀏覽器得到支援。請注意,例如,在 Safari 中不支援一次點擊登入。

如何啟用自動使用者註冊

您可以透過下列方式啟用使用者註冊:
- 啟用「設置 > WP Google 登入 > 啟用 Google 登入註冊」

或者

在 wp-config.php 檔案中添加
define( 'WP_GOOGLE_LOGIN_USER_REGISTRATION', 'true' );

注意:如果核取方塊為 ON,則有效的 Google 使用者會在 WordPress 的預設設置下註冊,詳情請見

「設置 > 一般 > 成員資格 > 任何人都可以註冊」核取方塊。

將使用者註冊限制為一個或多個域

默認情況下,當您透過常數 WP_GOOGLE_LOGIN_USER_REGISTRATION 或啟用「設置 > WP Google 登入 > 啟用 Google 登入註冊」以註冊使用者時,它將為任何 Google 登入(包括 gmail.com 使用者)創建使用者。如果您計劃在私人內部網站上使用此外掛,則可能希望將使用者註冊限制為單個 Google Suite 組織中的使用者。此配置變數可以實現此目的。

在「WP Google 登入 > 白名單域名」中添加您的域名,不帶任何模式前綴和 www,。您可以使用逗號分隔多個域名。請參見下面的示例,了解如何透過常數執行此操作:
define( 'WP_GOOGLE_LOGIN_WHITELIST_DOMAINS', 'example.com,sample.com' );

注意:如果使用者已存在,無論他們的域名是否在白名單中,他們都將可以使用 Google 登入。白名單僅會防止使用非白名單域名的電子郵件地址註冊使用者。

掛鈎

有關所有掛鈎的列表,請參閱此文檔。

wp-config.php 參數列表

WP_GOOGLE_LOGIN_CLIENT_ID(字符串):您應用程式的 Google 客戶端 ID。

WP_GOOGLE_LOGIN_SECRET(字符串):您的應用程式的秘密金鑰。

WP_GOOGLE_LOGIN_USER_REGISTRATION(布林值)(可選):如果要啟用新的使用者註冊,請設置為 true。如果未設置常數,則使用者註冊會遵循 設置 > 一般設置 > 成員資格 的設置。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.4.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Log in with Google」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

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

Create a project from Google Developers Console if none exists.

Go to Credentials tab, then create credential for OAuth client.

Application type will be Web Application
Add YOUR_DOMAIN/wp-login.php in Authorized redirect URIs

This 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' );

Browser support
These browsers are supported. 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.
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!

延伸相關外掛

文章
Filter
Apply Filters
Mastodon