-2

I have simple module with few forms fields and I would like to verify "humanity" before submitting.I have tried ReCaptcha::get('html'); but I am sure that there is something missing. I would appreciate any suggestions.

mat_88
  • 7
  • 1
  • 3
  • There are many plugins available in Joomla Extension Directory. You can download, install and enable them in your Joomla site. Then putting the code given by them in your module should do the work. – jaibatrik Apr 30 '12 at 14:18
  • You can try this-http://stackoverflow.com/questions/12840015/how-to-use-joomla-recaptcha-plugin-to-my-custom-module/12860744#12860744 – Irfan Oct 16 '12 at 11:37

1 Answers1

4

Try the following steps:

1) Get Google Recaptcha keys from here>>

2) Set these keys to recaptcha plugin and activate it if it's not.

3) Put below code where you want to show recaptcha:

//php code:

JPluginHelper::importPlugin('captcha');

$dispatcher = JDispatcher::getInstance();

$dispatcher->trigger('onInit','dynamic_recaptcha_1');

//html code inside form tag:

<div id="dynamic_recaptcha_1"></div>

4) Put this code where you validating/processing the form

$post = JRequest::get('post');      
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
if(!$res[0]){
    die('Invalid Captcha');
}

For more:

see docs.joomla.org>>

Vijaya Pandey
  • 4,252
  • 5
  • 32
  • 57