Jump to content

Added hCaptcha to WHMCS contact form


robetus

Recommended Posts

I have successfully added hCaptcha to my WHMCS checkout using the hook:

<?php

if (!defined("WHMCS")) die("This file cannot be accessed directly");

function limitOrders($vars)
	{
	$url = 'https://hcaptcha.com/siteverify';
	$privatekey = "my-private-key";
	$response = file_get_contents($url . "?secret=" . $privatekey . "&response=" . $_POST['g-recaptcha-response'] . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
	$data = json_decode($response);
	if (isset($data->success) AND $data->success == true)
		{
		// everything is ok!
		}
	  else
		{
			{
			global $errormessage;
			$errormessage.= "<li> Please, confirm that you are not a robot! <br/></li>";
			} //if CC
		}
	} //function
	
add_hook("ShoppingCartValidateCheckout", 1, "limitOrders");

and the following html code in checkout.tpl:

<script src="https://www.hcaptcha.com/1/api.js" async defer></script>
                    <center><div class="h-captcha" data-sitekey="my-sitekey"></div></center><br>

Is there an easy to make this work on the submitticket.php?step=2 page which is what I use for my contact form? Recaptcha doesn't work well for my site and I'm getting to much spam with WHMCS' built in captcha which is really bad.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated