Author Topic: Invisible reCAPTCHA [SOLVED]  (Read 1423 times)

guardiano78

  • Jr. Member
  • **
  • Posts: 287
    • C.S.S. Informatica
Invisible reCAPTCHA [SOLVED]
« 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

guardiano78

  • Jr. Member
  • **
  • Posts: 287
    • C.S.S. Informatica
Re: Invisible reCAPTCHA
« Reply #1 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.

guardiano78

  • Jr. Member
  • **
  • Posts: 287
    • C.S.S. Informatica
Re: Invisible reCAPTCHA [SOLVED]
« Reply #2 on: October 30, 2019, 21:13:18 pm »
Hello,
for fix the issue, i imported the plugin in virtuemart registration view page.

Thank you.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10040
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Invisible reCAPTCHA [SOLVED]
« Reply #3 on: October 31, 2019, 08:07:16 am »
Please share your knowledge with the project and post how you solved it.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

guardiano78

  • Jr. Member
  • **
  • Posts: 287
    • C.S.S. Informatica
Re: Invisible reCAPTCHA [SOLVED]
« Reply #4 on: October 31, 2019, 09:50:51 am »
Hello Milbo,
i added the following code:
Code: [Select]
<?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

  • Jr. Member
  • **
  • Posts: 335
    • MGSCreativa - Professional VM!
Re: Invisible reCAPTCHA [SOLVED]
« Reply #5 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

Code: [Select]
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
Code: [Select]
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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 400
    • MiniJoomla
  • VirtueMart Version: 3
Re: Invisible reCAPTCHA [SOLVED]
« Reply #6 on: May 12, 2020, 18:13:38 pm »
Quote
Hi! 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 from products, orders and database table
Virtuemart Email Manager - customs email templates

skawars

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Invisible reCAPTCHA [SOLVED]
« Reply #7 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.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4336
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Invisible reCAPTCHA [SOLVED]
« Reply #8 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