Social Login

Browse the docs Guide 10 of 29

Social Login lets users sign in with Google, Microsoft, Apple, GitHub, LinkedIn, or Facebook instead of typing a WordPress password every time. It can appear on the native WordPress login screen and on the Guard Dog frontend login form.

Supported Providers

ProviderRequirementsNotes
GoogleOAuth Client ID and Client SecretUses Google identity scopes for email and profile.
MicrosoftApplication Client ID and Client SecretUses a clean callback URL without query strings for Azure compatibility.
AppleServices ID, Team ID, Key ID, and .p8 private keyRequires an Apple Developer account.
GitHubOAuth App or GitHub App Client ID and Client SecretReads the verified primary email from GitHub’s email list.
LinkedInClient ID and Client Secret from a LinkedIn appUses Sign In with LinkedIn using OpenID Connect.
FacebookApp ID and App Secret from a Meta appFacebook never confirms email addresses, so matching by email always goes through a confirmation email.

All providers use this callback URL:

https://yoursite.com/guard-dog/oauth/callback

Use the exact URL shown in Guard Dog -> Authentication -> Social Login. If WordPress is installed in a subdirectory, the displayed URL may include that path.

Enable Social Login

  1. Go to Guard Dog -> Authentication -> Social Login.
  2. Check Enable Social Login.
  3. Enable one or more providers.
  4. Add the provider credentials.
  5. Save settings.
  6. Test in a private browser window.

Buttons only appear when Social Login is globally enabled and at least one provider is enabled and fully configured.

Google Setup

  1. Open Google Cloud Console.
  2. Create or choose a project.
  3. Configure the OAuth consent screen.
  4. Create an OAuth 2.0 Client ID for a web application.
  5. Add the Guard Dog callback URL as an authorized redirect URI.
  6. Copy the Client ID and Client Secret into Guard Dog.
  7. Enable Google in Guard Dog and save.

Use Google when most users already have Gmail or Google Workspace accounts.

Microsoft Setup

  1. Open Microsoft Azure Portal.
  2. Go to App registrations and create an app.
  3. Copy the Application (client) ID.
  4. Create a client secret under Certificates & secrets.
  5. Add the Guard Dog callback URL as a redirect URI.
  6. Copy the Application ID and Client Secret into Guard Dog.
  7. Enable Microsoft in Guard Dog and save.

Microsoft works with personal Microsoft accounts and organizational accounts supported by the Azure app registration.

Guard Dog never trusts the email address Microsoft sends. Microsoft doesn’t confirm that it’s verified, and trusting it would let an account in one Microsoft tenant claim an email address that belongs to another and take over the matching WordPress account. With Auto-Link by Email or Auto-Create Users on, Guard Dog emails a confirmation link to that address first (see Confirmation emails). Otherwise, people sign in another way once, then link Microsoft from their WordPress profile. After that, Microsoft sign-in works directly.

Apple Setup

Apple setup is fussier, so go slowly. Tiny mistakes here can make sign-in fail in very quiet, very annoying ways.

  1. Open Apple Developer.
  2. Create or choose a Services ID for Sign in with Apple.
  3. Add your domain and return URL.
  4. Use the Guard Dog callback URL as the Return URL.
  5. Copy the Services ID into Guard Dog.
  6. Copy your Apple Team ID into Guard Dog.
  7. Create a Sign in with Apple key and copy the Key ID.
  8. Paste the full .p8 private key contents into Guard Dog.
  9. Enable Apple in Guard Dog and save.

The Apple private key is stored encrypted. If you migrate hosts or change WordPress salts and Apple login starts failing, re-paste the raw .p8 private key and save again.

GitHub Setup

You can use either a GitHub OAuth App or a GitHub App.

  1. On GitHub, open Settings -> Developer settings, then OAuth Apps or GitHub Apps, and create a new app.
  2. Set the Authorization callback URL to the Guard Dog callback URL.
  3. For a GitHub App only: under Account permissions, set Email addresses to Read-only. An OAuth App needs nothing extra, because Guard Dog asks for the user:email scope when someone signs in.
  4. Generate a client secret.
  5. Copy the Client ID and Client Secret into Guard Dog.
  6. Enable GitHub in Guard Dog and save.

GitHub’s profile doesn’t say whether its email address is verified. Guard Dog reads the user’s email list instead, and trusts only the address GitHub marks as both primary and verified. If the primary address isn’t verified, Guard Dog confirms it by email before Auto-Link by Email or Auto-Create Users use it (see Confirmation emails). If the list can’t be read, which happens when a GitHub App lacks the Email addresses permission, an account already linked to that GitHub account still signs in.

LinkedIn Setup

  1. Open the LinkedIn Developer Portal and create an app.
  2. On the Products tab, add Sign In with LinkedIn using OpenID Connect.
  3. On the Auth tab, add the Guard Dog callback URL as an Authorized redirect URL.
  4. Copy the Client ID and Client Secret into Guard Dog.
  5. Enable LinkedIn in Guard Dog and save.

LinkedIn confirms an email address by marking it verified, but it documents that mark as optional. Guard Dog trusts the address only when LinkedIn says it’s verified. When LinkedIn leaves the mark out, Guard Dog confirms the address by email before Auto-Link by Email or Auto-Create Users use it (see Confirmation emails). An account already linked to that LinkedIn member signs in directly either way.

LinkedIn gives each app its own member IDs. If you switch to a different LinkedIn app later, existing LinkedIn links stop matching, and everyone will need to link LinkedIn again.

Facebook Setup

  1. In Meta for Developers, create an app with the Authenticate and request data from users with Facebook Login use case.
  2. In the use case’s permissions, make sure email is added alongside public_profile.
  3. In Facebook Login -> Settings, add the Guard Dog callback URL under Valid OAuth Redirect URIs.
  4. From App settings -> Basic, copy the App ID and App Secret into Guard Dog.
  5. Enable Facebook in Guard Dog and save.

While the app is in Development mode, only people with a role on the app can sign in with it, which is enough for testing with your own account. Before switching it to Live, Facebook requires a privacy policy URL and a way to request data deletion. In App settings -> Basic, under User data deletion, choose Data deletion callback URL and enter the URL shown in Guard Dog’s Facebook settings:

https://yoursite.com/guard-dog/oauth/facebook/data-deletion

How Facebook sign-in differs from the other providers:

  • Email is always confirmed first. Facebook never says whether an email address is verified, so Auto-Link by Email and Auto-Create Users always send a confirmation email before linking or creating anything. An account already linked to that Facebook account signs in directly.
  • The email can be missing. People can decline to share their email with your app. Guard Dog asks Facebook to request it again on their next sign-in. Until they share it, they can only connect Facebook from their WordPress profile after signing in another way.
  • No profile pictures. Facebook’s picture links expire, so a Facebook sign-in never changes the user’s avatar.
  • IDs belong to your app. Facebook gives each app its own user IDs, so links made with one app never match another. Changing or removing the App ID therefore deletes the old app’s Facebook data, as described below, and everyone will need to link Facebook again.
  • Graph API version. Guard Dog pins the Graph API version it calls, and updates it in new releases. To use a different version before then, return it from the guard_dog_social_facebook_graph_api_version filter, for example v27.0.

Facebook data deletion requests

When someone removes your app in their Facebook settings and asks for their data to be deleted, Facebook sends a signed request to the data deletion callback URL. Guard Dog checks the signature with your App Secret, then:

  • removes the link between that Facebook account and any WordPress account here;
  • deletes any sign-in from that Facebook account that is waiting for email confirmation, including a confirmation email not sent yet;
  • replaces that Facebook account’s ID, the email Facebook sent at each sign-in, and the email and name recorded when an account was created from it, with [deleted] in past activity log entries, keeping the entries themselves.

The same removal runs for every Facebook account when you change or remove the App ID, since the old app’s links can’t be used and its deletion requests can no longer be verified. If that removal fails, neither the App ID nor the App Secret is changed, and the settings page says to try saving again. Reset All Settings removes the Facebook data the same way before it deletes the credentials, and resets nothing if that fails.

Guard Dog doesn’t delete WordPress accounts. If the person wants their account removed too, use Tools -> Erase Personal Data or delete the user.

Facebook gets back a confirmation code and a status page link, which it shows to the person. The page confirms the request was completed and when. Every validly signed request gets a code, whether or not anyone here had linked that Facebook account, so the answer never reveals who has. If a database step fails, Facebook gets an error instead of a code, so a deletion is never confirmed while data is left behind. The failure is recorded in the activity log and the PHP error log, and the request can be sent again safely. One narrow case isn’t covered: if that same person clicks a confirmation email at the very moment Facebook’s request arrives, the click can still complete. Facebook removes the app’s access before it sends the request, so a new sign-in can’t start.

The endpoint works even while Social Login is turned off, since the data may still be stored. Facebook’s servers must be able to reach it: if a firewall or bot protection in front of your site blocks requests that don’t come from a browser, allow this URL.

Saved secrets

Once a client secret or the Apple private key is saved, its field shows ******** instead of the real value, so secrets never appear in the page source. Leave the stars to keep the saved value, type or paste over them to replace it, or clear the field and save to remove it.

General Settings

When enabled, Guard Dog links a provider account to an existing WordPress user when the provider email matches the WordPress account email.

Leave this disabled if your site treats email ownership as sensitive or if accounts may share addresses.

Auto-Create Users

When enabled, Guard Dog creates a new WordPress user when a social login succeeds and no matching account exists.

This works independently of WordPress’s Anyone can register setting (Settings > General). You can keep password sign-up closed and still let people sign up through a social provider.

Set the New User Role carefully. For public sites, Subscriber is the usual starting point.

With auto-create on, anyone with a verified account at an enabled provider can get an account on your site. For that reason, the New User Role list leaves out any role that can manage users or site settings, install or edit plugins and themes, or post unfiltered HTML. That rules out Administrator, and on single sites Editor too, because unfiltered HTML lets an editor plant script that runs in an administrator’s browser. If a privileged role was saved before this check existed, Guard Dog gives new social users your site’s default role, or Subscriber, instead, and the settings screen says so.

To relax the rule, filter the list of capabilities that make a role off-limits. For example, this allows Editor by dropping unfiltered_html:

add_filter( 'guard_dog_social_privileged_capabilities', function ( array $capabilities ): array {
	return array_values( array_diff( $capabilities, array( 'unfiltered_html' ) ) );
} );

Confirmation emails

Some providers don’t confirm that an email address is verified. That’s always true of Facebook and Microsoft, sometimes of LinkedIn, and of GitHub when the primary address isn’t verified. Guard Dog never links or creates an account on such an address alone. With Auto-Link by Email or Auto-Create Users on, it emails that address a confirmation link instead, and the sign-in page says to check your email.

  • The link only confirms. Opening it links the provider account to the WordPress account with that address, or creates the new account. It doesn’t sign anyone in: the person then signs in with the provider again, so the provider login and two-factor authentication still apply. The link opens the page the sign-in started from, such as your login form, so signing in from there still goes where the person was headed.
  • Same browser, within an hour, once. The link only works in the browser that started the sign-in, it expires an hour after that sign-in, and it can be used once. Requiring the same browser stops a stranger from signing in with their own provider account using your address and getting it linked when you click the email.
  • Checked again on click. If the email setting was turned off, the account’s email changed, or someone took the address for a new account in the meantime, the link is refused.
  • Limited. At most three confirmation emails per address, and per provider account, per hour.
  • Nothing to learn. The “check your email” message is the same whether or not an account uses that address, and whether or not an email was sent. The sign-in response doesn’t even take longer when an email goes out: the email is sent just after, by WP-Cron, so timing can’t give it away either.

If WP-Cron is turned off on your site (DISABLE_WP_CRON), the confirmation email goes out the next time your server’s cron job runs WordPress cron.

To change the confirmation email’s wording, colors or logo, use the Social Sign-In Confirmation template under Guard Dog → Appearance → Email Templates. Keep the {account} placeholder and the security notice, so the email still names the provider account and tells people to ignore it if they didn’t sign in. See Email Templates.

Bypass 2FA

When disabled (the default), social login meets Guard Dog two-factor authentication the same way a password login does. Anyone with 2FA turned on enters their code after the provider signs them in, and required 2FA setup still applies.

When enabled, a successful social login skips Guard Dog two-factor authentication for everyone, including required setup.

Use this only when you trust the provider’s account security policy for your users. For admin-heavy sites, keeping 2FA required is usually the safer call.

To narrow the bypass without turning it off for everyone, use the guard_dog_social_bypass_two_factor filter. It receives the setting’s value, the user and the provider id. For example, this skips 2FA for social logins except for administrators:

add_filter( 'guard_dog_social_bypass_two_factor', function ( bool $bypass, WP_User $user, string $provider_id ): bool {
	return $bypass && ! user_can( $user, 'manage_options' );
}, 10, 3 );

Where Buttons Appear

Social login buttons can appear on:

  • The native WordPress login screen
  • Your custom login URL screen
  • The Guard Dog frontend login form

For embedded login pages, use:

[guard_dog_login_form show_social_login="true"]

Or add the Guard Dog Login Form block and enable Show social login buttons.

Account Linking

Logged-in users can link and unlink social accounts from their WordPress profile when Social Login is enabled. Linked accounts are stored by provider and provider user ID, so changing a user’s WordPress email does not break an already-linked provider account.

Adding a Provider (Developers)

A plugin can add its own provider with the guard_dog_social_providers filter. Add an instance of a class that implements Guard_Dog_Social_Provider_Interface, keyed by its get_id():

add_filter( 'guard_dog_social_providers', function ( array $providers ): array {
    $providers['acme'] = new My_Acme_Provider();
    return $providers;
} );
  • IDs are 1 to 32 lowercase letters, digits and hyphens, with at least one letter and no underscores. login, auto, new and bypass are reserved for Guard Dog’s own settings.
  • Settings: the provider gets its own section under Social Login, generated from get_settings_fields(). Each field is stored as guard_dog_social_{id}_{field}. Field ids are 1 to 64 lowercase letters, digits, hyphens and underscores. A field can’t use the id enabled, because that’s the provider’s on/off switch, and no two fields can share an id. Text values (label, description, warning, placeholder) must be strings, and a sanitize_callback must be callable.
  • Optional extras: implement Guard_Dog_Social_Provider_Setup_Help_Interface for custom wording in that section. Implement Guard_Dog_Social_Provider_Enricher_Interface to add data after the login, such as an API call with the access token.
  • Timing: add the filter from your plugin’s main file or on plugins_loaded. Guard Dog reads the providers once, the first time it needs them.
  • Built-in providers can’t be replaced or removed. Turn one off in the settings instead.
  • Icons are filtered to a safe subset of SVG before they reach the login screen.

An entry that breaks a rule is skipped, and the others still load. With WP_DEBUG on, the reason is reported as a _doing_it_wrong() notice, which goes to debug.log when WP_DEBUG_LOG is set.

Security Notes

  • Guard Dog validates OAuth state tokens and uses single-use state metadata.
  • Provider credentials should never be shared publicly.
  • Apple callbacks use form_post, so Apple setup must use the exact callback URL.
  • Social login records are cleaned up when linked WordPress users are deleted.

Troubleshooting

Buttons do not appear

Check all of these:

  • Social Login is enabled globally.
  • The provider is enabled.
  • Required provider credentials are saved.
  • The provider callback/redirect URL matches the URL shown in Guard Dog.
  • The current login surface allows social buttons.

Provider says redirect URI mismatch

Copy the callback URL from Guard Dog and paste it into the provider configuration exactly. Watch for http vs https, www vs non-www, and subdirectory installs.

Apple login fails after a migration

Re-paste the raw .p8 private key into Guard Dog and save. Encrypted keys depend on the WordPress security salts, so host migrations or salt changes can make an old encrypted key unreadable.

Sign-in says to check your email

The provider didn’t confirm the email address, so Guard Dog sent a confirmation link to it (see Confirmation emails). If no email arrives, check spam. Nothing is sent when there’s nothing to confirm, for example when no account uses that address and Auto-Create Users is off, or after three emails in an hour. The message is the same either way, so it can’t reveal which addresses have accounts. If WP-Cron is turned off, the email waits for your server’s cron job.

Open the link in the browser where you started signing in. If you opened the email on a different device, sign in again from that device to get a new link.

Sign-in says the provider did not share an email address

The provider sent no email address at all, so there’s nothing to confirm or match. On Facebook, this happens when the person declines to share their email; they can try again and allow it. Otherwise, have the person sign in another way once, then link the provider from their WordPress profile. After that, provider sign-in works directly.

A user gets linked to the wrong account

Disable auto-link by email and unlink the provider account from the user profile. Then have the correct logged-in user link the provider manually.

Social login succeeds but users still get 2FA

Check Bypass 2FA in Social Login settings. If it is disabled, Guard Dog still requires 2FA for accounts that need it.


← Frontend Login Form | Documentation Home | Email Provider Configuration →