如何将Recaptcha插入我的自定义joomla 2.5模块中? [英] How to insert recaptcha into my custom joomla 2.5 module ?

查看:94
本文介绍了如何将Recaptcha插入我的自定义joomla 2.5模块中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的模块,几乎没有表单字段,我想在提交之前验证人性".我已经尝试过ReCaptcha :: get('html');但我敢肯定,这里缺少一些东西. 任何建议,我将不胜感激.

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.

推荐答案

尝试以下步骤:

1)从此处>>

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');
}

更多信息:

请参见 docs.joomla.org >>

这篇关于如何将Recaptcha插入我的自定义joomla 2.5模块中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆