News:

Looking for documentation? Take a look on our wiki

Main Menu

Invisible reCAPTCHA [SOLVED]

Started by guardiano78, October 29, 2019, 12:57:44 PM

Previous topic - Next topic

guardiano78

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

guardiano78

#1
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.

guardiano78

Hello,
for fix the issue, i imported the plugin in virtuemart registration view page.

Thank you.

Milbo

Please share your knowledge with the project and post how you solved it.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

guardiano78

#4
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

razor7

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
}*/
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

pinochico

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?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

skawars

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.

Studio 42

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

barbara

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?

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

kolokotronis

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>