Custom component show cahptcha
<?php echo JCaptcha::getInstance( 'recaptcha' )->display( 'captcha', 'captcha', 'captcha' ); ?>
and controller
$jinput = JFactory::getApplication()->input;
$post = $jinput->getArray($_POST);
$code = $post["g_recaptcha_response"]; //here we have the catcha code to validate
//call captcha plugin to validate code
JPluginHelper::importPlugin('captcha');
$dispatcher = JEventDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$code);
if ($res[0] === false) {
die("Invalid Captcha");
} else {
die("Valid Captcha");
}
true if vaild
false if faild
Always False
Setting | Value
PHP Built On | Windows NT DESKTOP-I8R3T2F 10.0 build 17134 (Windows 10) AMD64
Database Type | mysql
Database Version | 5.5.45
Database Collation | utf8_general_ci
Database Connection Collation | utf8mb4_general_ci
PHP Version | 7.2.7
Web Server | Microsoft-IIS/10.0
WebServer to PHP Interface | cgi-fcgi
Joomla! Version | Joomla! 3.8.11 Stable [ Amani ] 31-July-2018 14:00 GMT
Joomla! Platform Version | Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
For correction
In files /plugins/captcha/recaptcha/recaptcha.php
$g_recaptcha_response = $input->get('g-recaptcha-response', '', 'string');
if (!empty($code)){
$response = $code;
} elseif (!empty($g_recaptcha_response)) {
$response = $g_recaptcha_response;
} else {
$response = '';
}
Information was taken from this branch
https://issues.joomla.org/tracker/joomla-cms/7921
Labels |
Added:
?
|
Category | ⇒ | Plugins |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-08-16 15:49:35 |
Closed_By | ⇒ | franz-wohlkoenig |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/21643