In a custom extension if the captcha plugin is initialized manually like so:
JPluginHelper::importPlugin('captcha');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onInit','my_captcha_div');
<div id="my_captcha_div"></div>
To display the google reCaptcha field
No reCaptcha shown.
// recaptcha.php
case '2.0':
$theme = $this->params->get('theme2', 'light');
$file = 'https://www.google.com/recaptcha/api.js?hl=' . JFactory::getLanguage()->getTag() . '&render=explicit';
JHtml::_('script', $file, true, true);
$document->addScriptDeclaration('jQuery(document).ready(function($) {$(window).load(function() {'
. 'grecaptcha.render("' . $id . '", {sitekey: "' . $pubkey . '", theme: "' . $theme . '"});'
. '});});'
);
break;
// recaptcha.php
else
{
$file = 'https://www.google.com/recaptcha/api.js?onload=JoomlaInitReCaptcha2&render=explicit&hl=' . JFactory::getLanguage()->getTag();
JHtml::_('script', $file);
JHtml::_('script', 'plg_captcha_recaptcha/recaptcha.min.js', false, true);
}
The issue lies in the recent refactoring of the onInit
method of the plugin where it ignores the element id set upon init and since the plg_captcha_recaptcha/recaptcha.min.js
script's JoomlaInitReCaptcha2
is not updated by the plugin params it looks for a div
element like this one:
<div id="my_captcha_div"
class="g-recaptcha"
data-sitekey="xxxxxxxxxxxxxx"
data-theme="xxxx"
data-size="xxxx"></div>
After this modification it works.
The issue lies in the fact that the extensions using the plugin in this fashion will have to either add the key manually (not a good option) or make some changes to make it work. I'm posting this as a reference too.
Category | ⇒ | Plugins |
Labels |
Added:
?
|
Closed as stated above
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-06 19:55:09 |
Closed_By | ⇒ | brianteeman |
@arrowthemes Your container div should look like this:
<div id="your-div-id"
class="g-recaptcha" // <---- has to have this class
data-sitekey="xxxxxxxxxxxxxx" // <---- has to have this
data-theme="xxxx"
data-size="xxxx"></div>
or differently put
<div class="g-recaptcha" data-sitekey="ENTER_HERE_SITEKEY" data-theme="light" data-size="compact"></div>
For the plugin setup you can also see this.
If that fails I'd suggest looking in the above comment #8867 and the links referenced there and the div setup here. If nothing works, show me some code and I'd be happy to help further.
i think this has already responded by @Fedik in another PR.
See #8867 (comment)