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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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 bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.