Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module

Discuss the Blog Module.

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

Blog Comment Protection using Recaptcha


Reply

2 Posts   1383 Views

Avatar
Bruce

18 July 2010 at 10:12pm (Last edited: 18 July 2010 10:13pm), Community Member, 29 Posts

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?

Avatar
Chris_Bryer

5 February 2014 at 6:58pm Community Member, 35 Posts

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