Oct 11 2008

[Full Post] Mollom Captcha For Silverstripe

By Dieter Orens | 5 Reactions so far… | 0 Trackbacks

Long time since I've done a real post, but here we go.

As we all know, spam has been a huge problem for years now, and for a contact form of one of the silverstripe projects I was involved in we needed some kind of spam protection.

Now there was already the recaptcha module, which added a captcha field provided by Recaptcha, but as I'm actually more of a fan of Mollom, I thought it would be nice to have the Mollom Captcha field added as well.

So here you go, a 'Mollom CaptchaField Module' for Silverstripe.

Under the hood I gracefully used the Mollom PHP class by Tijs Verkoyen, so most of the credit really goes to him.

Note that I manually hardcoded the serverlist in _config.php, I'm not sure this is really the way to go.

For it to work you'll have to get a public and a private key for your domain on the Mollom - website and set this in the _config.php file of the mollomcaptchafield directory. As long as it doesn't work, you won't see the field showing up.

To initiate it on your custom forms, it works like any other form field:

new MollomCaptchaField("MyCaptcha", "Label Text");

You can also add this field to your RequiredFields like you would with any other field.

If all goes well it should add something like this to your custom form:

SS Mollom Captcha Field

You'll see the field also has a 'listen' link. This will download an .mp3 which lets disabled users hear what they have to type when they're having difficulties reading it. The link has an id 'mollom_audio', so you can style it as you please.

For SS legacy reasons, it also still has the 'span class="middleColumn" element in, in case you're wondering why I didn't leave that out.

Download at Mollom for Silverstripe.

Cheerz.

PS: I might look into making a complete Mollom module some day, so not just the Captcha field. 

Comments

  1. Joseph Ku

    Joseph Ku said:

    Hi, I have applied it, but it doesn't work, could u pls troubleshoot for me? First I obtained the pub and pri keys, then i uploaded folder, added in the , then run a db/build and could not seem to see anything has changed? please help!

    Posted 2 months ago

  2. Dieter Orens

    Dieter Orens said:

    Hi Joseph,

    You have to add the field explicitly to your Form code where you create your fields.

    It's not working on userdefined forms that you've created through the cms, if that is what you're looking for.

    Posted 2 months ago

  3. Joseph Ku

    Joseph Ku said:

    Thanks for your reply. I thought it will get built in to the Silverstripe out of the box forms. I will basically need to create a custom php form, and add the line of code into the php file right?

    Posted 2 months ago

  4. Dieter Orens

    Dieter Orens said:

    Yes that is right, you'll need to create your own php form.

    It's currently not possible yet to go on out-of-the-box forms.

    Thanks

    Posted 2 months ago

  5. Andrew Houle

    Andrew Houle said:

    Awesome work, thanks for the alternate captha for ss!

    Posted 1 month ago

Trackbacks

No trackbacks on this post.

Trackback-url for this post

http://www.dio5.com/mollom-captcha-for-silverstripe/trackback

Post your comment

Code-help

Pressing ENTER 2 times makes a new paragraph. Some XHTML allowed:

  • Bold: <strong>text</strong>

  • Italic: <em>text</em>

  • Link: <a href="http://www.website.com" title="My title">My website</a>

URL's with http:// are automatically converted to links.

Get the RSSFeed for the comments on this article.