VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: guardiano78 on October 29, 2019, 12:57:44 PM

Title: Invisible reCAPTCHA [SOLVED]
Post by: guardiano78 on October 29, 2019, 12:57:44 PM
Hello,
I can't get the plugin to work with the badge.
I followed the simple instructions on this page:
https://www.joomla.it/blog/8982-attivare-invisible-recaptcha-su-joomla-3-9.html

but without success.
I forget something? or the plugin does not work?

Thanks.

Joomla 3.9.9
Title: Re: Invisible reCAPTCHA
Post by: guardiano78 on October 29, 2019, 13:23:33 PM
ok, i discovered that it works only for joomla contact form.
If i check "Use Recaptcha for registration" in virtuemart, Recaptcha v3  doesn't works.

Anyone knows if is it possible to make it work wherever are displayed form module? for example registration/edit virtuemart profile page and checkout page?

thanks.
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: guardiano78 on October 30, 2019, 21:13:18 PM
Hello,
for fix the issue, i imported the plugin in virtuemart registration view page.

Thank you.
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: Milbo on October 31, 2019, 08:07:16 AM
Please share your knowledge with the project and post how you solved it.
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: guardiano78 on October 31, 2019, 09:50:51 AM
Hello Milbo,
i added the following code:

<?php
JPluginHelper::importPlugin('captcha''recaptcha_invisible'); 
$dispatcher JDispatcher::getInstance();
$dispatcher->trigger('onInit','jform_captcha'); 

$plugin JPluginHelper::getPlugin('captcha''recaptcha_invisible');
$params = new JRegistry($plugin->params);
?>

<div id="jform_captcha" class=" required g-recaptcha" data-sitekey="<?php echo $params->get('public_key''default_value'?>" data-badge="<?php echo $params->get('badge''default_value'?>" data-size="invisible" data-tabindex="0" data-callback="" data-expired-callback="" data-error-callback="" data-recaptcha-widget-id="0"></div>

I'm not sure this is the right way, anyway it works ... waiting for native implementation :-)
maybe someone can try and give me feedback.

bye
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: razor7 on May 12, 2020, 17:50:20 PM
Hi! in my case I changed renderCaptcha helper function in /components/com_virtuemart/helpers/shopfunctionsf.php and changed $id and $reCaptchaName

static public function renderCaptcha($config = 'reg_captcha',$id = 'dynamic_recaptcha_invisible_1'){

if(VmConfig::get ($config) and JFactory::getUser()->guest==1 ){

$reCaptchaName = 'recaptcha_invisible'; // the name of the captcha plugin - retrieved from the custom component's parameters

JPluginHelper::importPlugin('captcha', $reCaptchaName); // will load the plugin selected, not all of them - we need to know what plugin's events we need to trigger

$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onInit', $id);
$output = $dispatcher->trigger('onDisplay', array($reCaptchaName, $id, 'class="g-recaptcha required"'));
return isset($output[0])? $output[0]:'';
}
return '';
}


Then in the user edit template changed the hardcoded recaptcha display code by this
echo $this->captcha;
// captcha addition
/*if(VmConfig::get ('reg_captcha')){
JHTML::_('behavior.framework');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
?>
<div id="dynamic_recaptcha_1"></div>
<?php
}*/
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: pinochico on May 12, 2020, 18:13:38 PM
QuoteHi! in my case I changed renderCaptcha helper function in /components/com_virtuemart/helpers/shopfunctionsf.php and changed $id and $reCaptchaName

I am not sure of the correct reason for this development.
If my developer modifies the core code of VirtueMart without proper justification, I will not accept it.

In my opinion, there is no reason to modify the core code of VitueMart and it is better to keep the original proposed modification for loading the captcha plugin in the template.

The next time you upgrade, the edit will not be overwritten.

What do you think about it?
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: skawars on May 19, 2020, 13:59:54 PM
Could razor7 or guardiano78 please explain how to test this and prove it is working?

I have tried both methods, and can see the correct JS includes in the head of the source, and what I think is the correct dix within the user registration template file. When I register new users, I'm not seeing any requests appear in my Google reCaptcha console.

Here is the snippet appearing in the registration form:

<div id="dynamic_recaptcha_invisible_1" class="required g-recaptcha" data-sitekey="[sitekey]" data-badge="bottomright" data-size="invisible" data-tabindex="0" data-callback="" data-expired-callback="" data-error-callback=""></div>

I'm trying razor7's method with the change to the helper function at the moment, but tried guardiano78's suggestion beforehand with similar results.
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: Studio 42 on May 19, 2020, 22:44:37 PM
Invisible recaptcha work on Joomla registration too(without core hacks).
So if Vm follow the core way to render recaptcha, it should work with any captcha plugins
For eg a code to adapt here https://joomla.stackexchange.com/questions/15856/how-can-i-use-google-recaptcha-in-my-custom-page
and
https://stackoverflow.com/questions/28065375/how-to-add-recaptcha-to-contact-form

Not that on init  the id need not to be set in Joomla 3 and the Joomla trigger onCheckAnswer do not need post values. But to prevent google namespace problem with other form, it's better too use own ID for eg. vm_captcha_field
Title: Re: Invisible reCAPTCHA [SOLVED] - please clarify?
Post by: barbara on December 15, 2020, 03:08:07 AM
This thread is marked solved - but I dont see a way to actually get the invisible recaptcha working on the registration form?!

What am I missing?
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: jenkinhill on December 15, 2020, 10:26:50 AM
http://forum.virtuemart.net/index.php?topic=145984.0
Title: Re: Invisible reCAPTCHA [SOLVED]
Post by: kolokotronis on December 29, 2020, 22:57:22 PM
Hi and happy new year, i  have the same problem and i make a template override /html/com_virtuemart/user/edit.php

i change code and i add a code from a friend added at this post eariler guardiano78

//stAn - with hidden config of reg_captcha_logged=1 we can trigger captcha for logged in if needed as well, or add user input filter plugin for antispam

JPluginHelper::importPlugin('captcha', 'recaptcha_invisible');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onInit','jform_captcha');

$plugin = JPluginHelper::getPlugin('captcha', 'recaptcha_invisible');
$params = new JRegistry($plugin->params);
?>
<div id="jform_captcha" class=" required g-recaptcha" data-sitekey="<?php echo $params->get('public_key''default_value'?>" data-badge="<?php echo $params->get('badge''default_value'?>" data-size="invisible" data-tabindex="0" data-callback="" data-expired-callback="" data-error-callback="" data-recaptcha-widget-id="0"></div>