ReCaptcha disappears from Joomla 2.5 Registration

What?
This is an extract from a forum which solved our problem for why the ReCaptcha part disappears from the user registration form. We have Joomla 2.5.16 installed and no new updates for a plugin that comes with Joomla 2.5 install.

How?
Source: Joomla! • View topic - Cannot get recaptcha to display on registration form...
There are two solutions I have found that fix the problem:

Method #1
I prefer this method as it changes less code and is more likely to be supported in a Joomla update. Open the file /plugins/captcha/recaptcha/recaptcha.php and find the following 3 lines of code :
copyraw
const RECAPTCHA_API_SERVER = "http://api.recaptcha.net";
const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api";
const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net";
  1.  const RECAPTCHA_API_SERVER = "http://api.recaptcha.net"
  2.  const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api"
  3.  const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net"
and change these to
copyraw
const RECAPTCHA_API_SERVER = "http://www.google.com/recaptcha/api";
const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api";
const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net";
  1.  const RECAPTCHA_API_SERVER = "http://www.google.com/recaptcha/api"
  2.  const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api"
  3.  const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net"


Method #2
If method #1 didn't work for you then if the following code works, it's because Google have changed where they're storing the API (again).

This overrides the Core Joomla code for ReCaptcha:

1. Open the file: /plugins/captcha/recaptcha/recaptcha.php

2. Find the following string in the OnDisplay function:
copyraw
return '<div id="dynamic_recaptcha_1"></div>';
  1.  return '<div id="dynamic_recaptcha_1"></div>'
3. and replace with:
copyraw
// Replace YOUR_KEY with your public key

return '<div id="dynamic_recaptcha_1">
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=YOUR_KEY"></script>
<noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=YOUR_KEY" height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript>
<script type="text/javascript">
window.onload = function() {
Recaptcha.focus_response_field();
}
</script>
</div>';
	}
  1.  // Replace YOUR_KEY with your public key 
  2.   
  3.  return '<div id="dynamic_recaptcha_1"> 
  4.  <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=YOUR_KEY"></script> 
  5.  <noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=YOUR_KEY" height="300" width="500" frameborder="0"></iframe><br> 
  6.  <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> 
  7.  <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript> 
  8.  <script type="text/javascript"> 
  9.  window.onload = function() { 
  10.  Recaptcha.focus_response_field()
  11.  } 
  12.  </script> 
  13.  </div>'
  14.      } 

Additional
  • This applies to a case where the code WAS working and without any changes to the server (no updates), and the recaptcha simply stopped displaying.
  • Public Key and Private Key have been setup in the Joomla Core Plugin.
  • Set to display in both User Registration and Global Configuration.
  • K2 is NOT installed.
Category: Joomla :: Article: 538

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.