{"id":5482,"date":"2025-06-25T06:37:15","date_gmt":"2025-06-25T06:37:15","guid":{"rendered":"https:\/\/www.wizbrand.com\/tutorials\/?p=5482"},"modified":"2025-07-22T01:03:00","modified_gmt":"2025-07-22T01:03:00","slug":"allow-only-google-login-disable-email-registration-in-flarum","status":"publish","type":"post","link":"https:\/\/www.wizbrand.com\/tutorials\/allow-only-google-login-disable-email-registration-in-flarum\/","title":{"rendered":"Allow Only Google Login &amp; Disable Email Registration in Flarum"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Working Code<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Hide the 'Sign Up' button\/link from the homepage and header *\/\n.item-signUp, \n.Button--signUp,\na&#91;href=\"\/register\"],\nli.item-signUp,\nbutton.Button--signUp {\n    display: none !important;\n}\n\n\/* Hide everything inside the .SignUpModal modal that is NOT an OAuth social login button *\/\n.SignUpModal .Modal-body .Form-group,\n.SignUpModal .Modal-body .Form--centered,\n.SignUpModal .Modal-body .Form .Form-group,\n.SignUpModal .Modal-body .Button&#91;type=\"submit\"],\n.SignUpModal .Modal-body label,\n.SignUpModal .Modal-body .item-signUp,\n.SignUpModal .Form .Form-group {\n  display: none !important;\n}\n\n\/* Make sure the OAuth\/Google button remains visible *\/\n.LogInButtonContainer,\n.LogInButtonContainer * {\n  display: block !important;\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p>By default, Flarum allows users to register with an email and password. If you want to <strong>force all signups and new users to use only Google Login (OAuth)<\/strong>, you\u2019ll need to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enable Google OAuth.<\/li>\n\n\n\n<li>Disable or hide standard email registration.<\/li>\n\n\n\n<li>Remove the &#8220;Sign Up&#8221; button from the interface.<\/li>\n<\/ul>\n\n\n\n<p>Follow these steps for a <strong>clean, secure, and Google-only signup experience<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Enable Registration in Flarum Settings<\/strong><\/h2>\n\n\n\n<p>First, you must <strong>keep registration enabled<\/strong> in the Flarum Admin Panel.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Do NOT disable \u201cAllow new users to register\u201d<\/strong>\u2014this must stay ON, or OAuth registration won\u2019t work.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Install and Configure the FoF OAuth Extension<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>SSH into your server<\/strong> where Flarum is installed.<\/li>\n\n\n\n<li>Run: <code>composer require fof\/oauth<\/code><\/li>\n\n\n\n<li>Go to your Flarum <strong>admin panel<\/strong> \u2192 <strong>Extensions<\/strong>, and enable \u201cFriendsOfFlarum OAuth\u201d.<\/li>\n\n\n\n<li>Click \u201cFoF OAuth\u201d settings and set up <strong>Google<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Get your <strong>Google OAuth Client ID and Secret<\/strong> from <a href=\"https:\/\/console.cloud.google.com\/apis\/credentials\">Google Cloud Console<\/a>.<\/li>\n\n\n\n<li>Use the <strong>redirect URL<\/strong> format:<br><code>https:\/\/yourdomain.com\/auth\/google<\/code><\/li>\n\n\n\n<li>Save your changes.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><em>Now, your forum will show a \u201cSign in with Google\u201d button in the login\/signup modal.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Hide Email Registration Form Fields<\/strong><\/h2>\n\n\n\n<p>Flarum displays the sign-up form as a <strong>pop-up modal<\/strong>. To hide all fields except Google OAuth, add the following CSS:<\/p>\n\n\n\n<p><strong>Go to<\/strong> <code>Admin Panel<\/code> \u2192 <code>Appearance<\/code> \u2192 <code>Custom CSS<\/code>, and paste:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Hide all standard registration fields in sign-up modal *\/\n.Modal--register .Form-group--email,\n.Modal--register .Form-group--username,\n.Modal--register .Form-group--password,\n.Modal--register .Form-group--terms,\n.Modal--register button&#91;type=\"submit\"] {\n    display: none !important;\n}\n\/* Optional: Hide 'Sign Up' header in modal *\/\n.Modal--register h2 {\n    display: none !important;\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Hide the \u201cSign Up\u201d Button Everywhere<\/strong><\/h2>\n\n\n\n<p>You also need to <strong>remove the Sign Up button\/link<\/strong> from the Flarum homepage, header, and mobile menu so users can\u2019t find the registration option unless they use Google.<\/p>\n\n\n\n<p><strong>Add this CSS (you can combine it with above in Custom CSS):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Hide the 'Sign Up' button\/link from the homepage, header, and menus *\/\n.item-signUp, \n.Button--signUp,\na&#91;href=\"\/register\"],\nli.item-signUp,\nbutton.Button--signUp {\n    display: none !important;\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. Optional: Change Login Text or Add a Note<\/strong><\/h2>\n\n\n\n<p>To help users, consider clarifying that <strong>only Google sign-up is available<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <a href=\"https:\/\/discuss.flarum.org\/d\/5222-flarum-linguist\">Linguist extension<\/a> to change registration\/login text.<\/li>\n\n\n\n<li>Or add a <strong>custom message<\/strong> in the modal using the <a href=\"https:\/\/discuss.flarum.org\/d\/7585-custom-html-widget\">Custom HTML extension<\/a>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. Test the Experience<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log out or use incognito mode.<\/li>\n\n\n\n<li>Visit your Flarum site.\n<ul class=\"wp-block-list\">\n<li>The \u201cSign Up\u201d button\/link should be <strong>gone<\/strong>.<\/li>\n\n\n\n<li>Trying to register (via direct link) should show <strong>only the Google login button<\/strong>.<\/li>\n\n\n\n<li>Email\/password sign-up is fully hidden.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>New users can sign up ONLY using Google.<\/li>\n\n\n\n<li>Existing users can still log in with Google (if their account is linked).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Summary Table<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Step<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td>Enable registration<\/td><td>Required for OAuth registration to work<\/td><\/tr><tr><td>Install FoF OAuth<\/td><td>Adds Google login option<\/td><\/tr><tr><td>Hide email registration fields<\/td><td>Only show Google in registration modal<\/td><\/tr><tr><td>Hide \u201cSign Up\u201d button<\/td><td>Removes registration entry points<\/td><\/tr><tr><td>Test<\/td><td>Ensure only Google login is available<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQ<\/strong><\/h2>\n\n\n\n<p><strong>Q: Can tech-savvy users still sign up using email via API?<\/strong><br><em>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.<\/em><\/p>\n\n\n\n<p><strong>Q: Can I use this for other OAuth providers?<\/strong><br><em>A: Yes, just configure other providers in FoF OAuth and use similar CSS.<\/em><\/p>\n\n\n\n<p><strong>Q: What if I want to allow both Google and email?<\/strong><br><em>A: Don\u2019t hide the email\/password fields.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>References<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/discuss.flarum.org\/d\/21473-friendsofflarum-oauth\">Flarum Discuss: FoF OAuth Extension<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.flarum.org\/customizing\/css\">Flarum Docs: Customizing CSS<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/discuss.flarum.org\/d\/5222-flarum-linguist\">Flarum Linguist Extension<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Working Code Introduction By default, Flarum allows users to register with an email and password. If you want to force [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5482","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/posts\/5482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/comments?post=5482"}],"version-history":[{"count":2,"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/posts\/5482\/revisions"}],"predecessor-version":[{"id":5606,"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/posts\/5482\/revisions\/5606"}],"wp:attachment":[{"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/media?parent=5482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/categories?post=5482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wizbrand.com\/tutorials\/wp-json\/wp\/v2\/tags?post=5482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}