News:

Support the VirtueMart project and become a member

Main Menu

Joomla 3.5 the captcha is no more visible

Started by patbe60, March 22, 2016, 13:31:46 PM

Previous topic - Next topic

biltong

Yes, this worked for me:

Quote from: mirrorsandglass on March 23, 2016, 17:56:13 PM
It works if I comment out line 63 and add the following to the else for the version check at line 61. in [ROOT]/plugins/captcha/recaptcha/recaptcha.php :
$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);

$document = JFactory::getDocument();
$theme = $this->params->get('theme', 'clean');
$document->addScriptDeclaration('jQuery(document).ready(function($) {$(window).load(function() {'
. 'grecaptcha.render("' . $id . '", {sitekey: "' . $pubkey . '", theme: "' . $theme . '"});'
. '});});'
);

I assume it isn't finding plg_captcha_recaptcha/recaptcha.min.js possibly due to a wrong path?

in resolving these problems:

Quote from: biltong on April 06, 2016, 15:09:09 PM
Joomla 3.5.1 has no mention of Captcha fixes.

Just tested my installation again with J3.5.1 and VM 3.0.14 on Firefox 45.0.1 with these results:

Does not show on VM 'Recommend to a friend' and 'Ask a Question' even with Beez template. When you click Submit, it displays 'The CAPTCHA solution was incorrect.'
      
Does however show and work on VM Cart / Checkout page when clicking on the Forgot Password and Forgot Username links.

stAn99: I prefer elegant solutions myself but time does not permit at the moment!

misholini

Quote from: mirrorsandglass on March 23, 2016, 17:56:13 PM
It works if I comment out line 63 and add the following to the else for the version check at line 61. in [ROOT]/plugins/captcha/recaptcha/recaptcha.php :
$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);

$document = JFactory::getDocument();
$theme = $this->params->get('theme', 'clean');
$document->addScriptDeclaration('jQuery(document).ready(function($) {$(window).load(function() {'
. 'grecaptcha.render("' . $id . '", {sitekey: "' . $pubkey . '", theme: "' . $theme . '"});'
. '});});'
);

I assume it isn't finding plg_captcha_recaptcha/recaptcha.min.js possibly due to a wrong path?
Thanks for that! It works but not 100%, if you go to Backend>Extensions>Plugins>Captcha-Recaptcha and try to resize the Recaptcha it would not work. Which means that Recaptcha 2 is stuck to its Default size and viewed from Mobile device it is far from responsive - does not fit on mobile screen well. If the output resolved to Compact size it would have been different story but the above fix does not fix this (the option to rsize Recaptcha 2 in Backend is redundant).
Please note the difference between the sizes as per attached image.

biltong

misholini - I'm getting the same as you, Compact is same as Default size and not responsive.

J3.5.1, VM 3.0.14, PHP 5.6.19

misholini

Recaptcha 2 runs ok for me on another extension (Alfcontact) and resizes between Defaulft and Compact size fine with the original code in recaptcha.php and without the fix below:
//JHtml::_('script', 'plg_captcha_recaptcha/recaptcha.min.js', false, true);

$document = JFactory::getDocument();
$theme = $this->params->get('theme', 'clean');
$document->addScriptDeclaration('jQuery(document).ready(function($) {$(window).load(function() {'
. 'grecaptcha.render("' . $id . '", {sitekey: "' . $pubkey . '", theme: "' . $theme . '"});'
. '});});'
);


Commenting out below line only breaks  working Recaptcha in my Alfcontact:
//JHtml::_('script', 'plg_captcha_recaptcha/recaptcha.min.js', false, true);
.. So I remove the comment and bring this line to it's original state.
I also keep the rest of the patch above to keep unhappy extensions including Virtuemart in order for them to show Recaptcha 2. Unfortunately the size of Recaptcha 2 in Virtuemart can not be controlled via the plugin's settings (Default, Compact).

If Recaptcha 2 works fine with some extensions without the necessity to patch the recaptcha.php file then I hope this will be the case with Virtuemart soon.

JurgenG

After half a day and trying multiple workaround options I finally found 1 that is close to perfect (on Joomla 3.5.1 in combination with VM 3.0.16).

First make sure that Captha is enabled and the key are inserted within the default Joomla plug-in.
Enable Captcha - ReCaptcha on Joomla > Global Configuration > site.
Set Captcha to - Use Default - on Joomla > Global configuration > Users.

Check Use Captcha for Registration on VM > Configuration > SHOP.
Check Use ReCaptcha for recommendations and 'Ask a question' onVM > Configuration > SHOPFRONT.

Now to edit the php files in the overides (for now until VM implements this). All the forms and captcha request are the same. Search for "// captcha addition" to find its correct location within the form file where the captacha is requested.
For example Ask a Question: Original file located at \componentes\com_virtuemart\views\askquestion\tmpl\form.php
Overide file: <your template> > html > com_virtuemart > askquestion > form.php around line 103 change:

// captcha addition
if(VmConfig::get ('ask_captcha')){
JHTML::_('behavior.framework');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
?>
<div id="dynamic_recaptcha_1"></div>
<?php 
}
// end of captcha addition 


to
// captcha addition
if(VmConfig::get ('ask_captcha')){

JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onInit','dynamic_recaptcha_1');
$recaptcha = $dispatcher->trigger('onDisplay', array(null, 'dynamic_recaptcha_1', 'class=""'));
?><?php echo (isset($recaptcha[0])) ? $recaptcha[0] : '';?>

<?php 
}
// end of captcha addition 


Kind regards