How to enable google Captcha in Flarum?

To enable Google reCAPTCHA in Flarum, you’ll need to use an extension that supports reCAPTCHA integration. FoF reCAPTCHA is a commonly used extension for Flarum that allows you to integrate Google’s reCAPTCHA into your forum to prevent spam and automated sign-ups.

Here’s a step-by-step guide on how to enable Google reCAPTCHA in Flarum using the FoF reCAPTCHA extension:


Step 1: Install FoF reCAPTCHA Extension

  1. SSH into your server and navigate to your Flarum installation directory.
  2. Run the following command to install the FoF reCAPTCHA extension via Composer:bashCopy codecomposer require fof/recaptcha
  3. After the installation is complete, clear the Flarum cache:bashCopy codephp flarum cache:clear
  4. Enable the extension:
    • Go to your Flarum Admin Panel (https://yourdomain.com/admin).
    • Navigate to the Extensions tab.
    • Find the FoF reCAPTCHA extension and enable it.

Step 2: Get Google reCAPTCHA API Keys

You need to get the Site Key and Secret Key from Google to integrate reCAPTCHA with your Flarum forum.

  1. Go to the Google reCAPTCHA Admin Console.
  2. Register a new site:
    • Label: Enter a name for your site (e.g., “WakilSahab Flarum Forum”).
    • reCAPTCHA Type: Choose reCAPTCHA v2 and select either:
      • “I’m not a robot” Checkbox or
      • Invisible reCAPTCHA (depending on your preference).
    • Domains: Add your forum domain, e.g., wakilsahab.in.
    • Owners: Enter your email address.
  3. Accept the reCAPTCHA Terms and click Submit.
  4. You will be provided with the Site Key and Secret Key. Keep these keys handy.

Step 3: Configure reCAPTCHA in Flarum

  1. Go back to your Flarum Admin Panel and navigate to Extensions > FoF reCAPTCHA settings.
  2. Enter the Site Key and Secret Key you got from Google.
  3. Configure the following options:
    • reCAPTCHA Type: Choose between Checkbox or Invisible reCAPTCHA, depending on what you configured in Google reCAPTCHA.
    • Enable reCAPTCHA on Login/Registration: You can enable reCAPTCHA for:
      • Registration forms (to prevent bot sign-ups).
      • Login forms (to prevent brute force attacks).
  4. Save the settings.

Step 4: Test Google reCAPTCHA Integration

  1. Logout from the admin panel and go to the registration page or login page.
  2. You should now see the Google reCAPTCHA challenge (either the checkbox or invisible reCAPTCHA based on your choice).
  3. Try signing up or logging in to make sure the reCAPTCHA works as expected.

Optional: Adjust reCAPTCHA Behavior

  • If you want to tweak the reCAPTCHA’s sensitivity, you can adjust the security settings in the Google reCAPTCHA Admin Console.
  • You can also disable reCAPTCHA for specific forms (like login) in the FoF reCAPTCHA extension settings.

Troubleshooting

  • reCAPTCHA not showing: Ensure that you’ve correctly entered the Site Key and Secret Key and that the reCAPTCHA API is enabled for the domain you entered in Google’s Admin Console.
  • Cache issues: If the reCAPTCHA doesn’t appear after enabling, try clearing Flarum’s cache again:bashCopy codephp flarum cache:clear
  • Test on different browsers: Sometimes browser settings or extensions can block reCAPTCHA. Test the functionality on different browsers to ensure it’s working properly.