Jump to:

1036 Posts in 810 Topics by 315 members

Forum Module

SilverStripe Forums » Forum Module » SilverStripe forums + Recaptcha module

Discuss the Forum Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1210 Views
  • forumq42
    Community Member
    12 Posts

    SilverStripe forums + Recaptcha module Link to this post


    I had SilverStripe 2.4.x + the Forum module + Recaptcha (+Spam Protection module) working on a fresh install of SilverStripe. However, repeating the same steps on the production server I seem to be getting the response:

    "Your answer didn't match the captcha words, please try again"

    after submitting the Forum user registration form, even when the Recaptcha is obviously correct.

    I'm wondering if there's some domain/keys issue. I've tried using public/private global keys for both the domain of the URL (http://foo.bar.org) and the hostname of the actual web servers (let's say: server1.gronk.org).

    The steps I have done are basically:

    - installed Forum module
    - installed Recaptcha into /html/recaptcha
    - registered w/google.com/recaptcha and generated a public/private keypair for the domain I am using
    - installed Spam Protection module into /html/spamprotector
    - /dev/build on the site
    - ?flush=1 on the site

    - in /mysite/_config.php added 3 lines:
    RecaptchaField::$public_api_key = '<public key copied from google.com/recaptcha>';
    RecaptchaField::$private_api_key = '<private key copied from google.com/recaptcha>'';

    - in /forums/code, edited 2 files: ForumMemberProfile.php, ForumRole.php

    ForumMemberProfile.php, added this line under line 165 the check "if(class_exists('SpamProtectionManager')":
    $protector = SpamProtectorManager::update_form($form, 'MyCaptcha'); // to make the recaptcha work with your form

    ForumRole.php, added a recaptca field under line 171 to the $personalDetailsField form code:
    new RecaptchaField('MyCaptcha')

    A Recpatcha image box appears but 100% of the time after the form is submitted the response is:
    "Your answer didn't match the captcha words, please try again"

    and the user is not registered but rather brought back to the form back to try again. Is there something obvious I am forgetting?


  • forumq42
    Community Member
    12 Posts

    Re: SilverStripe forums + Recaptcha module Link to this post


    The issue was neither the keys nor any sort of firewall issue.

    The issue was there were 2 captcha fields being created, and they must have been one on top of the other on the page because it appeared only 1 was on the page when the registration form appeared. However after submitting and looking at the network traffic it was obvious 2 challenges were being sent to Google/recaptcha. The first returned as correct, the second always returning incorrect. Additionally, looking at the page source there were 2 different regions that called recaptcha Javascript code which looked suspicious.

    I had added the line:
    $protector = SpamProtectorManager::update_form($form, 'MyCaptcha');

    to ForumMemberProfile.php and also added a Recaptcha field to the forum. From what I gather, the Spam Protection module must generate that on it's own when it's configured to use Recaptcha so in essence I had added a 2nd field. I removed the added 2 lines and things were working. Checking the network traffic there was then only a single challenge to Google/recaptcha.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.