Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » Blog Comment Protection using Recaptcha

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 1330 Views
  • Bruce
    Avatar
    Community Member
    29 Posts

    Blog Comment Protection using Recaptcha Link to this post

    How can I get recaptcha to protect the blog module comments?

    I have installed the spamprotection & recaptcha modules, and I have successfully got them running on some customised forms (a contact us form).
    http://www.silverstripe.org/all-other-modules/show/267893#post267893

    I cannot however, see how to get the recaptcha to appear on the blog module comments.
    I have had to add MathSpamProtection in the meantime, but I would prefer the recaptcha

    Here's the /mysite/_config I am using :

    SpamProtectorManager::set_spam_protector("RecaptchaProtector");
    RecaptchaField::$public_api_key = 'code';
    RecaptchaField::$private_api_key = 'code';

    // field creation (Should this even be here?)
    $recaptchaField = new RecaptchaField('MyCaptcha');
    $recaptchaField->jsOptions = array('theme' => 'clean'); // optional

    PageComment::enableModeration();
    MathSpamProtection::setEnabled();

    any suggestions?

  • Chris_Bryer
    Avatar
    Community Member
    35 Posts

    Re: Blog Comment Protection using Recaptcha Link to this post

    this is an old post but heres the solution for ss 3.1. it'd be easy to turn this into a module too.

    :::php
    class CommentSpamProtectionExtension extends DataExtension {

       public function alterCommentForm(Form $form){
          SpamProtectorManager::update_form($form, 'Comment');
          return $form;
       }
    }

    ::yml _config.yml
    CommentingController:
    extensions:
    - CommentSpamProtectionExtension

    1330 Views
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.