1) Get recaptcha keys from http://www.google.com/recaptcha

2) Set these keys to recaptcha plugin and activate it if it's not.

3) Put below code where you want to show recaptcha

php code:

$dispatcher = JDispatcher::getInstance();

html code inside form tag

<div id="dynamic_recaptcha_1"></div>

I putted this code in my htmp page:

$post = JFactory::getApplication()->input->post;
$dispatcher = JEventDispatcher::getInstance();
    die('Invalid Captcha');

I placed the above code but after submitting the form I receive a blank page. Can you explain why?

  • A blank page is a PHP error page with disabled error reporting. Enable it for development.
    – Anibal
    Mar 26, 2016 at 13:28

2 Answers 2


First read carefully in which files the SO answer that you quoted tells you to put the code.

Also, the code you attached is no longer working in Joomla 3.5. This is due to a change in the reCaptcha plugin. You have to use it like so:

$dispatcher = JEventDispatcher::getInstance();

And instead of creating a container like this:

<div id="my_captcha_div"></div>

create one like the one below:

<div id="my_captcha_div" 

Check here also for more information.

For Joomla 3.5 and above use the response from Олег Косарев.

see https://www.1joomla.org/2016/11/display-recaptcha-in-your-custom.html


Joomla 3.x Correct

    $joomla_captcha = JFactory::getConfig()->get('captcha');
if ( $joomla_captcha != '0') {
    $dispatcher = JDispatcher::getInstance();
    // This will put the code to load reCAPTCHA's JavaScript file into your <head>
    $dispatcher->trigger('onInit', 'dynamic_recaptcha_1');
    // This will return the array of HTML code.
    $recaptcha = $dispatcher->trigger('onDisplay', array(null, 'dynamic_recaptcha_1', 'class="required"'));


if (isset($recaptcha[0]) and $joomla_captcha != "0") {
        echo $recaptcha[0];

Or replace the three lines above with a shorthand line because $recaptcha is not defined if $joomla_captcha is 0.

echo (isset($recaptcha[0])) ? $recaptcha[0] : '';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.