Skip to content

Social Login ​

Sign-in with Google, GitHub, Facebook, Apple, Microsoft or LinkedIn on the site; the accounts are linked to WordPress users.

kitloom/social-accounts · admins: kitloom/social-accounts-filament, kitloom/social-accounts-nova

Video lessons ​

Recorded in the Filament admin; the Nova admin works the same way.

Linked Accounts
Social Login Settings

Sign-in with Google, GitHub, Facebook, Apple, Microsoft or LinkedIn on the site, as Nextend Social Login gives a WordPress site: a visitor presses "Continue with Google", comes back signed in. The account is linked to a WordPress user; a site that comes from WordPress with the plugin keeps every account its visitors linked there. The admin is kitloom/social-accounts-filament or kitloom/social-accounts-nova.

It is for the site's visitors. The admins keep their own sign-in.

Setting it up ​

Social Login → Settings, for each service:

  1. Make an OAuth app at the service (below).
  2. Give it the redirect URI the settings page shows: https://your-site/auth/google/callback, https://your-site/auth/apple/callback, … A site that moved from Nextend had wp-login.php?loginSocial=google there: add the new address (or replace the old one).
  3. Copy the app's id and secret into the settings and switch the service on.

A service shows a button only when it is switched on and has both keys (Apple: its team and key ids too). The secret is stored encrypted with the application key and never shown again; a field left empty keeps the saved one. If the application key changes, enter the secret again.

ServiceWhere the app is madeWhat to copy
GoogleGoogle Cloud console → Create credentials → OAuth client ID → Web applicationClient ID, client secret
GitHubSettings → Developer settings → OAuth Apps → New OAuth AppClient ID, client secret
FacebookMeta for Developers → My Apps → Create app, with the Facebook Login product; Settings → BasicApp ID, app secret. The redirect URI goes under Facebook Login → Settings → Valid OAuth Redirect URIs; the app must be live (or the visitor a tester) and ask for the email permission
AppleCertificates, Identifiers & Profiles: an App ID with Sign in with Apple, a Services ID configured for it with the site's domain and the redirect URI, and a Key for Sign in with Apple, downloaded once as a .p8 fileService ID (the identifier, site.example.signin), the .p8 file's contents as the private key, the Team ID (top right of the account) and the Key ID
MicrosoftMicrosoft Entra admin center → App registrations → New registration, a Web platform with the redirect URI; Certificates & secrets → New client secretApplication (client) ID, the secret's value. Tenant: empty is common (personal, work and school accounts); consumers is personal accounts only, organizations work and school, or the id of one directory — as the registration's Supported account types says
LinkedInLinkedIn Developers → My apps → Create app, with the product Sign In with LinkedIn using OpenID Connect; Auth → Authorized redirect URLsClient ID, client secret

Apple signs the visitor in with a private key, not a secret from its console: the module makes the short-lived client secret Apple wants from the key on every trip, so nothing expires after six months as a hand-made one does. Apple sends the visitor back with a POST from its own site; the site takes it at the same address and goes on as with any other service. A visitor who hides their address gets one at Apple's private relay (…@privaterelay.appleid.com): mail to it arrives only from a sender registered with Apple (Services → Sign in with Apple for Email Communication) — the site's mail domain.

Other settings:

SettingDefaultWhat
Link accounts by email addressonA visitor whose address at the service belongs to a user signs in as that user, and the account is linked. Only an address the service has verified counts, and only a user whose address is theirs: one who signed up on the site, or changed the address on the account page, opens a password reset link first
Login pageemptyThe theme's page with the login form: a sign-in that went wrong comes back here. Empty — back to the page the button was pressed on

New visitors become users only while Settings → General → «Anyone can register» is on, with the «New User Default Role». Otherwise only existing users can sign in this way.

Who signs in ​

When a visitor comes back from the service:

  1. The account is linked to a user — that user signs in.
  2. A user has the address the service vouches for — the account is linked to them and they sign in (unless linking by address is off). A user who typed that address in themselves at the site's sign-up, the shop's or the checkout's, or whose address was changed afterwards — on the account page, a profile page of an admin, or by an admin — is not joined until a password reset link sent there is opened (kitloom_email_unverified in wp_usermeta, Kitloom\WpSchema\Users\EmailProof): whoever signed up first with someone else's address would otherwise share that person's account. Users an admin made, imported ones and those a service made keep linking as before.
  3. Registration is open — a new user is made from the account's name and address, and signs in.
  4. Otherwise the visitor goes back to the login page — or the page they pressed the button on — with a reason.

Which address a service vouches for: Google, Apple and LinkedIn say so of the one they give (email_verified); GitHub hands over the primary address only once verified, Facebook gives none until confirmed. Microsoft vouches for a personal account's address (Outlook, Xbox); a work or school account's address is whatever its directory says, and any directory may sign in through the common tenant, so such an address counts only when Entra vouches for the domain — add the optional claim xms_edov to the app registration's ID token (Token configuration). Without it a work account signs in once linked, or once its user signed in with the password and linked it, and cannot sign up.

A user with two-factor authentication (kitloom/two-factor) still types the code: the sign-in waits for it, the visitor is sent to the code page. A social sign-in is remembered, as the plugin does.

A signed-in user who presses a button links that account to themselves; an account linked to someone else is refused. One account per service per user. A deleted user's accounts are deleted with them.

For the theme ​

GET    /auth/google?redirect=/account/   the button: off to Google, back to /account/
GET    /auth/google/callback             where Google sends the visitor back
POST   /auth/apple/callback              where Apple sends the visitor back; sent on to the GET
DELETE /auth/google                      unlink from the signed-in user (JSON: {"unlinked": true})

On a site in several languages (kitloom/languages) a button on a French page carries ?lang=fr: a visitor with no redirect comes back to the French front page, /fr/, and a refusal comes back there too.

The buttons, with their addresses — for the services that are on:

php
use Kitloom\SocialAccounts\Facades\SocialLogin;

SocialLogin::buttons('/account/');
// [['provider' => 'google', 'label' => 'Google', 'url' => '…/auth/google?redirect=%2Faccount%2F',
//   'linked' => null, 'unlinkUrl' => null], …]   linked: true/false for a signed-in user

[nextend_social_login] in content gives the theme the same buttons; provider="google,apple,facebook" picks and orders them, redirect is where to come back to, heading, style and align are passed as written.

Every page also carries the part socialLogin (Kitloom\SocialAccounts\Site\SocialLoginPart): the same buttons, coming back to that page — for the theme's own sign-in form. The Vue themes here draw both: the shortcode in a page's text, the part under the sign-in form of the shop's account page (Pantry).

On the site's Account page (Settings → Reading, kitloom/site) a signed-in user has the section Linked accounts (?section=linked-accounts) while a service is on: the same buttons in its data, coming back to the section.

What went wrong comes back as ?social_error=:

ReasonWhat happened
deniedThe visitor cancelled at the service, or the sign-in was not started in this browser
failedThe service could not be asked: wrong keys, no connection (the error is logged)
no_accountA new visitor, and registration is closed
no_emailA new visitor whose service gave no verified address
email_takenA user has that address and it may not be linked by it: sign in with the password, then link the account
linked_elsewhereThe account is linked to another user

Where it is kept ​

WhatWhere
Linked accountssocial_users, Nextend Social Login's table (the site's table prefix in front): ID the user, type google, github, facebook, apple, microsoft, linkedin, identifier the account's id at the service, register_date, login_date, link_date. Accounts of services the module does not know (X, Amazon) stay in the table and are listed
Settingswp_options: social_accounts_{google,github,facebook,apple,microsoft,linkedin}_enabled, …_client_id, …_client_secret (encrypted; Apple's private key), social_accounts_apple_team_id, social_accounts_apple_key_id, social_accounts_microsoft_tenant, social_accounts_link_by_email, social_accounts_login_url
ModelKitloom\SocialAccounts\Models\SocialAccount; an application swaps it with ModelRegistry::use(SocialAccount::KEY, …)

Personal data ​

With kitloom/privacy, Tools → Export Personal Data lists the accounts linked to the user the address belongs to — the service, the account's id there, when it was linked, signed up with and last signed in with. Erase Personal Data unlinks them all: the rows go from social_users, as when the user is deleted. The user stays and signs in with their password; pressing a button again links the account anew.

Configuration ​

php artisan vendor:publish --tag=kitloom-social-accounts-config: routes turns the addresses off, shortcodes.register the shortcode, privacy.register the personal data export and erasure, filament.register and nova.register the admins' sections.

Tests ​

From the application that installs the package: php vendor/bin/phpunit --testsuite SocialAccounts.

kitloom — sites on Laravel, built for you and run with AI.
Contact · Services · License · Refunds · Privacy · Community · YouTube · [email protected]