Want to use Joomla recaptcha plugin with my custom module? Follow the below steps to use recaptcha Joomla plugin in your custom module.
1) Get recaptcha keys from http://www.google.com/recaptcha
2) Set these keys to recaptcha plugin and activate it if it’s not.
3) Put below code where you want to show recaptcha
1 2 3 4 5 6 7 | //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
1 2 3 4 5 6 7 | $post = JRequest::get('post'); JPluginHelper::importPlugin('captcha'); $dispatcher = JDispatcher::getInstance(); $res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']); if(!$res[0]){ die('Invalid Captcha'); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.