如何在我的自定义模块中使用Joomla recaptcha插件? [英] How to use Joomla recaptcha plugin with my custom module?
本文介绍了如何在我的自定义模块中使用Joomla recaptcha插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为我的contactus表单创建了一个自定义模块.现在,我想在此模块中使用Joomla recaptcha插件.
I have created a custom module for my contactus form. Now I want to use Joomla recaptcha plugin with this module.
有什么想法要完成吗?
推荐答案
要使用joomla默认的recaptcha插件,请遵循以下步骤-
In order to use joomla default recaptcha plugin follow these steps-
1)从 http://www.google.com/recaptcha
2)将这些键设置为recaptcha插件,如果没有,则将其激活.
2)Set these keys to recaptcha plugin and activate it if it's not.
3)将下面的代码放在要显示Recaptcha的位置
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)将此代码放在验证/处理表单的位置
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');
}
//对于Joomla 3.x
//For Joomla 3.x
$post = JFactory::getApplication()->input->post;
$dispatcher = JEventDispatcher::getInstance();
这篇关于如何在我的自定义模块中使用Joomla recaptcha插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文