Captcha

Installing

Step 1: Make a new Google reCaptcha based on your unique domain name. First navigate to https://www.google.com/recaptcha/intro/. Here you need to add your domain information.

Captcha - Google reCaptcha Screen

Next, you need to get the public and private keys for your domain.

Captcha - Google reCaptcha Keys

After this you need to add the follow Javascript code to your admin/foundation/blueprint/scripts.php file. It comes preloaded, as it is a fundamental component of the CMS.

<script async defer src="https://www.google.com/recaptcha/api.js"></script>

Next, add the following code to draw the reCaptcha to your site.

<div class="captcha-container float-center">

<div class="captcha">

<div class="g-recaptcha float-center" data-sitekey="<?php echo $google['recaptcha_site_key']; ?>"></div>

</div>

</div>

Multiple Captchas

One major flaw with the vanilla Google reCaptcha service is that it does not allow multiple captchas to be used per page. If you wish to put more than two forms protected by captcha successfully then you need to install a special Javascript code and change some ids and classes around.

HTML Code

<div id="captcha1"></div>

<div id="captcha2"></div>

JS Code

If you need to add multiple captchas to your page use the follow code. Add the following script to your public_html/admin/foundation/blueprint/scripts.php file, replacing the one presently there.

<script async defer src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"></script>

<script async defer type="text/javascript">

var verifyCallback = function(response) {

alert(response);

};

var widgetId1;

var widgetId2;

var onloadCallback = function() {

widgetId1 = grecaptcha.render('captcha1', {

'sitekey' : "<?php echo $google['recaptcha_site_key']; ?>",

});

widgetId2 = grecaptcha.render(document.getElementById('captcha2'), {

'sitekey' : "<?php echo $google['recaptcha_site_key']; ?>"

});

};

</script>

And with that, you have added a feature that prevents robots and spammers from submitting your forms and causing chaos.

Sabali Co - CMS

CMS