?
avatar leskiapo
leskiapo
31 Mar 2016

Steps to reproduce the issue

Upgrade to 3.5.0 or install 3.5.0. Open standard contact form with Google Recaptcha enabled.

Expected result

Google Recaptcha should load/display.

Actual result

Google Recaptcha does not load/display.

System information (as much as possible)

Joomla 3.5.0 (either upgraded from earlier version or clean install)

Additional comments

Neither the label nor the recaptcha load. On all sites tested, recaptcha loaded as expected until upgrade to 3.5.0.

avatar leskiapo leskiapo - open - 31 Mar 2016
avatar brianteeman
brianteeman - comment - 31 Mar 2016

Please can you test with 3.5.1 release candidate 2 as there were some fixes made to the recapatcha that I think have been resolved https://github.com/joomla/joomla-cms/releases/tag/3.5.1-rc2


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9681.

avatar brianteeman brianteeman - change - 31 Mar 2016
Status New Information Required
avatar brianteeman brianteeman - change - 31 Mar 2016
Category Plugins
avatar ahvink
ahvink - comment - 31 Mar 2016

Fix to make your custom component work again with joomla's recaptcha:

<?php else : ?>
     <div class="g-recaptcha" data-sitekey=“YOUR_SITE_KEY" data-theme="light" data-size="normal"></div>
<?php endif; ?>


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9681.

avatar leskiapo
leskiapo - comment - 31 Mar 2016

That fixes the problem. I learned more about the issue after I posted this message. As it turns out, unless "Captcha - ReCaptcha" is set under Global Configuration > Site > Default Captcha, even though under "Global Configuration > Contacts > Form > Allow Captcha on Contact" was set to Captcha - Recaptcha, it would not work. You had to have it set to "Captcha - ReCaptcha" under the Site tab (Global Config). The patch fixed this and it now behaves as it did before the upgrade to 3.5.0.
Thanks!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9681.

avatar brianteeman brianteeman - change - 31 Mar 2016
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2016-03-31 22:35:33
Closed_By brianteeman
avatar brianteeman brianteeman - close - 31 Mar 2016
avatar brianteeman brianteeman - close - 31 Mar 2016
avatar fguyon
fguyon - comment - 9 Apr 2016

Hi
Thanx for the fix, but in which file to paste it ?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9681.

avatar ahvink
ahvink - comment - 9 Apr 2016

You need to change the html with which you call joomla's recaptcha plugin. So you need to edit your form's default.php file so it will show the recaptcha irrespective of your joomla version like this:

 <?php if (version_compare(JVERSION, '3.5', '<')) : ?>
       <div id="dynamic_recaptcha_1"></div>
 <?php else : ?>
       <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY" data-theme="light" data-size="normal"></div>
 <?php endif; ?>


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9681.

avatar ggppdk
ggppdk - comment - 9 Apr 2016

@ahvink

  • if you want to add a captcha field into a form without using the form element 'captcha' (via the XML of your form)

but you would like to instatiate it manually (and also do validation manually on the controller save task)
it is better to avoid adding the HTML / JS / etc of the captcha directly

  • it may break in the future

Instead the API display() method should be used
something like this will work with (please correct any syntax or other errors ...):

  • any captcha plugin
  • both J3.4.x / J3.5.x and future versions ?

FORM

$captcha_field_html = '';

// Use configured captcha plugin
if ( $c_plugin = JFactory::getApplication()->getCfg('captcha') )
{
    // Try to load the configured captcha plugin, (check if disabled or uninstalled)
    // Joomla will enqueue an error message if needed
    $captcha_obj = JCaptcha::getInstance($c_plugin, array('namespace' => 'my_component_form'));

    $captcha_field_html = $captcha_obj  ?
        $captcha_obj->display('captcha_field_name', 'captcha_tag_id', ' captcha_outer_class ')  :
        '' ;
}

CONTROLLER save task


// ** Extra validation for manually added captcha
// Use configured captcha plugin
if ( $c_plugin = JFactory::getApplication()->getCfg('captcha') ) 
{
    // Get captcha value
    $c_value = $app->input->get('captcha_field_name', null, 'STRING');

    // Get captch object instance
    $captcha_obj = JCaptcha::getInstance($c_plugin, array('namespace' => 'my_component_form'));

    // Validate catcha
    if (!$captcha_obj->checkAnswer($c_value))
    {
        // Get the captcha validation message and push it out to the user
        // but default error message is not good ? maybe use custom here
        $error = $captcha_obj->getError();
        $app->enqueueMessage($error instanceof Exception ? $error->getMessage() : $error, 'error');

        // Set POST form data into the session, so that they get reloaded
        $app->setUserState($form->option.'.edit.'.$form->context.'.data', $data);

        // Redirect back to the component form
        $this->setRedirect( '...' );
        return false;
    }
}

Add a Comment

Login with GitHub to post a comment