Print

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
Category: Joomla :: Article: 538