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

查看:13
本文介绍了如何将 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天全站免登陆