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
- SSH into your server and navigate to your Flarum installation directory.
- Run the following command to install the FoF reCAPTCHA extension via Composer:bashCopy code
composer require fof/recaptcha
- After the installation is complete, clear the Flarum cache:bashCopy code
php flarum cache:clear
- 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.
- Go to your Flarum Admin Panel (
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.
- Go to the Google reCAPTCHA Admin Console.
- 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.
- Accept the reCAPTCHA Terms and click Submit.
- You will be provided with the Site Key and Secret Key. Keep these keys handy.
Step 3: Configure reCAPTCHA in Flarum
- Go back to your Flarum Admin Panel and navigate to Extensions > FoF reCAPTCHA settings.
- Enter the Site Key and Secret Key you got from Google.
- 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).
- Save the settings.
Step 4: Test Google reCAPTCHA Integration
- Logout from the admin panel and go to the registration page or login page.
- You should now see the Google reCAPTCHA challenge (either the checkbox or invisible reCAPTCHA based on your choice).
- 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 code
php 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.