[SOLVED] Joomla AlphaRegistration ReCaptcha code not validating

Posted on: by

Tags:

If you are using AlphaRegistration 2.0.9 for user registration in Joomla 1.5.14, it is quite likely that you face some sort of problems with displaying or validating ReCaptcha, even if you have correct configuration, i.e., with valid public and private keys.For me, ReCaptcha was showing up on the website, but was accepting any code typed in to be correct. However, it was showing proper error code if the Recaptcha field was left blank.

After some searching, I came across a piece of code modification which a user named galaxidesigns had suggested in the AlphaPlug forum in this thread. Though the issue here was somewhat different, nevertheless, it worked.

So the solution was:
edit components/com_alpharegistration/views/register/view.html.php
Change the following code around line#92:

`// reCaptcha script` ` /*` ` if ( $arg_params->def( 'userecaptcha', 1 ) ) { ` ` $paramsReCaptcha = "var RecaptchaOptions = {` `    theme : '".$arg_params->get( 'themerecaptcha' )."',` `    lang  : '". substr($lang, 0, 2)."'` ` };";` ` $document->addScriptDeclaration($paramsReCaptcha, ''); ` ` }` ` */` ` /*` ` if ( $arg_params->def( 'userecaptcha', 1 ) ) { ` ` $document->addScript( "http://api.recaptcha.net/js/recaptcha_ajax.js" ); ` ` $paramsReCaptcha = "` ` window.onload = function () {` ` Recaptcha.create('". $arg_params->get( 'pubkey' )."',` ` 'recaptcha_div', {` `  theme: '". $arg_params->get( 'themerecaptcha', 'red' )."',` `  lang  : '". substr($lang, 0, 2)."',` `  callback: Recaptcha.focus_response_field` ` });` ` }"` ` ;` ` $document->addScriptDeclaration($paramsReCaptcha, '');` ` }` ` */` `if ( $arg_params->def( 'userecaptcha', 1 ) ) {` ` $document->addScript( "http://api.recaptcha.net/js/recaptcha_ajax.js" );` ` $paramsReCaptcha = "` ` $(window).load(function(){` ` Recaptcha.create('". $arg_params->get( 'pubkey' )."',` ` 'recaptcha_div', {` ` theme: '". $arg_params->get( 'themerecaptcha', 'red' )."',` ` lang : '". substr($lang, 0, 2)."',` ` callback: Recaptcha.focus_response_field` ` });` ` })"` ` ;` ` $document->addScriptDeclaration($paramsReCaptcha, '');` ` } `

Change the code to this:

// reCaptcha script

if ( $arg_params->def( ‘userecaptcha’, 1 ) ) {
$paramsReCaptcha = “var RecaptchaOptions = {
theme : '”.$arg_params->get( ‘themerecaptcha’ ).“',
lang  : '”. substr($lang, 0, 2).“’
};”;
$document->addScriptDeclaration($paramsReCaptcha, ‘’);
}

if ( $arg_params->def( ‘userecaptcha’, 1 ) ) {
$document->addScript( “http://api.recaptcha.net/js/recaptcha_ajax.js” );
$paramsReCaptcha = "
window.onload = function () {
Recaptcha.create(‘“. $arg_params->get( ‘pubkey’ ).”’,
‘recaptcha_div’, {
theme: ‘“. $arg_params->get( ‘themerecaptcha’, ‘red’ ).”’,
lang  : ‘“. substr($lang, 0, 2).”’,
callback: Recaptcha.focus_response_field
});
}"
;
$document->addScriptDeclaration($paramsReCaptcha, ‘’);
}

/*
if ( $arg_params->def( ‘userecaptcha’, 1 ) ) {
$document->addScript( “http://api.recaptcha.net/js/recaptcha_ajax.js” );
$paramsReCaptcha = "
$(window).load(function(){
Recaptcha.create(‘“. $arg_params->get( ‘pubkey’ ).”’,
‘recaptcha_div’, {
theme: ‘“. $arg_params->get( ‘themerecaptcha’, ‘red’ ).”’,
lang : ‘“. substr($lang, 0, 2).”’,
callback: Recaptcha.focus_response_field
});
})"
;
$document->addScriptDeclaration($paramsReCaptcha, ‘’);
}
*/

What is being done here is that a piece of code which was previously commented is being uncommented and a similar code which was being used is commented instead.

Hope this helps.

This work is licensed under a .