Adding ReCaptcha for K2 on Joomla

Step 1. Add your site on Google ReCaptcha

  1. Go to Google ReCaptcha
  2. Log in with your Google account
  3. Go to My Account
  4. Click “Add a New Site” button and enter your website URL
  5. You will get public and private keys for that site

Step 2. Activate and configure ReCaptcha on K2

  1. Log in your Joomla admin panel
  2. Go to Components > K2 > Parameters > Comments
  3. Click on K2 Parameters button on top-right menu
  4. Open Comments tab and set “Active reCaptcha” to Yes
  5. Open Advanced tab, go to the Anti-Spam section and paste the previously obtained public and private keys
  6. Save!

If it doesn’t work yet, in my case, I have had to modify some code. Open this file:

components/com_k2/views/item/view.html.php

and update the new repository URL:

//$document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js'); // Old URL
$document->addScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js'); // New URL

Also, in the same file, I needed to remove some lines (see the commented lines):

$js = '
  function showRecaptcha(){
    Recaptcha.create("'.$item->params->get('recaptcha_public_key').'", "recaptcha", {
    theme: "'.$item->params->get('recaptcha_theme', 'clean').'"
  });
 }

 //$K2(window).load(function() {
   showRecaptcha();
 //});
 ';

Categories

Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow

Comments

Developed and designed by Netgloo
© 2019 Netgloo