简体   繁体   English

Joomla简单的注册表格和验证码

[英]Joomla simple registration form and recaptcha

I'm stuck with Joomla registration form. 我坚持使用Joomla注册表格。 There are lots of fields in this form so I want to remove all of them and leave only email field. 此表单中有很多字段,因此我想删除所有字段,仅保留email字段。

Instead of writing my own extension I decided to use an extension called Simple Registration - Joomla! 我决定不使用自己的扩展程序,而是使用名为Simple Registration - Joomla!的扩展程序Simple Registration - Joomla! . This extension uses native com_user model and overrides only one method in its model. 此扩展使用本地com_user模型,并且仅覆盖其模型中的一个方法。

But the problem is that this module generates the form in its template. 但是问题在于该模块在其模板中生成表单。 HTML code is inserted manually, but Joomla native extension uses fieldset to generate the form. HTML代码是手动插入的,但是Joomla本机扩展使用字段集生成表单。 Captcha is also included in this fieldset. 验证码也包含在此字段集中。

That's why Simple registration form does not have captcha validation. 这就是为什么简单注册表格没有验证码验证的原因。 I've searched for examples where captcha is validated manually on this extension without success. 我搜索了一些示例,其中在此扩展程序上手动验证了验证码,但没有成功。

Any solutions? 有什么办法吗?

Well, i decided to implement an old solution that had several depreciated methods. 好吧,我决定实施一个旧的解决方案,该方法具有多种折旧方法。

    //get captcha result
    $post = $this->app->get('g-recaptcha-response');
    //load captcha plugun
    JPluginHelper::importPlugin('captcha');
    //get instance of the class that handles dispatching of events.
    $dispatcher = JEventDispatcher::getInstance();
    //check captcha results
    $res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response']);
    if(!$res[0]){
        die('Invalid Captcha Code');
    }

Thats all, meh. 就是这样,嗯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM