$100 Website Offer

Get your personal website + domain for just $100.

Limited Time Offer!

Claim Your Website Now

Allow Only Google Login & Disable Email Registration in Flarum

Uncategorized

Introduction

By default, Flarum allows users to register with an email and password. If you want to force all signups and new users to use only Google Login (OAuth), you’ll need to:

  • Enable Google OAuth.
  • Disable or hide standard email registration.
  • Remove the “Sign Up” button from the interface.

Follow these steps for a clean, secure, and Google-only signup experience.


1. Enable Registration in Flarum Settings

First, you must keep registration enabled in the Flarum Admin Panel.

Do NOT disable “Allow new users to register”—this must stay ON, or OAuth registration won’t work.


2. Install and Configure the FoF OAuth Extension

  1. SSH into your server where Flarum is installed.
  2. Run: composer require fof/oauth
  3. Go to your Flarum admin panelExtensions, and enable “FriendsOfFlarum OAuth”.
  4. Click “FoF OAuth” settings and set up Google:
    • Get your Google OAuth Client ID and Secret from Google Cloud Console.
    • Use the redirect URL format:
      https://yourdomain.com/auth/google
    • Save your changes.

Now, your forum will show a “Sign in with Google” button in the login/signup modal.


3. Hide Email Registration Form Fields

Flarum displays the sign-up form as a pop-up modal. To hide all fields except Google OAuth, add the following CSS:

Go to Admin PanelAppearanceCustom CSS, and paste:

/* Hide all standard registration fields in sign-up modal */
.Modal--register .Form-group--email,
.Modal--register .Form-group--username,
.Modal--register .Form-group--password,
.Modal--register .Form-group--terms,
.Modal--register button[type="submit"] {
    display: none !important;
}
/* Optional: Hide 'Sign Up' header in modal */
.Modal--register h2 {
    display: none !important;
}

4. Hide the “Sign Up” Button Everywhere

You also need to remove the Sign Up button/link from the Flarum homepage, header, and mobile menu so users can’t find the registration option unless they use Google.

Add this CSS (you can combine it with above in Custom CSS):

/* Hide the 'Sign Up' button/link from the homepage, header, and menus */
.item-signUp, 
.Button--signUp,
a[href="/register"],
li.item-signUp,
button.Button--signUp {
    display: none !important;
}

5. Optional: Change Login Text or Add a Note

To help users, consider clarifying that only Google sign-up is available.


6. Test the Experience

  • Log out or use incognito mode.
  • Visit your Flarum site.
    • The “Sign Up” button/link should be gone.
    • Trying to register (via direct link) should show only the Google login button.
    • Email/password sign-up is fully hidden.
  • New users can sign up ONLY using Google.
  • Existing users can still log in with Google (if their account is linked).

Summary Table

StepPurpose
Enable registrationRequired for OAuth registration to work
Install FoF OAuthAdds Google login option
Hide email registration fieldsOnly show Google in registration modal
Hide “Sign Up” buttonRemoves registration entry points
TestEnsure only Google login is available

FAQ

Q: Can tech-savvy users still sign up using email via API?
A: With this setup, nearly all practical sign-up is blocked, but the API endpoint is still technically available. For absolute enforcement, a small Flarum extension or web server rule is needed.

Q: Can I use this for other OAuth providers?
A: Yes, just configure other providers in FoF OAuth and use similar CSS.

Q: What if I want to allow both Google and email?
A: Don’t hide the email/password fields.


References


Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x