This hook checks user data, in order to prevent the user from registering or later editing his data using:

 

<?php
/**
* check user data
*
* This hook checks user data, in order to prevent the user from registering
* or later editing his data using:
* - fake or disposable email addresses (using https://www.mailcheck.ai/)
* free API service
* - special characters
* - too long strings
* @copyright DomainRegister
* https://domainregister.international
* info@domainregister.it
* License: GNU General Public License v3.0
*
*/

 

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

function checkuserdata($vars) {
  $email = $vars['email'];
  $elements = ['firstname','lastname','companyname','address1','address2','city','state','postcode','country','phonenumber','tax_id'];

  $usererrors = [];

  foreach($elements as $element){
    if (checkstring($vars[$element])){
      array_push($usererrors, "Your ".$element." contains invalid characters");
    }
    if (strlen($vars[$element])>150){
      array_push($usererrors, "Your ".$element." is too long");
    }
  }

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.mailcheck.ai/email/' . $email);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch);
  curl_close($ch);
  $response2=json_decode($response);
  $debug = var_export($response2, true);
  if ($response2->disposable OR !$response2->mx)
    { array_push($usererrors, "Your email address is not valid");
  }

  return $usererrors;
}

 

function checkstring ($string1)
{
  $invalidchars=str_split("£$%&/()=!#@?^[]<>");
  foreach($invalidchars as $character){
    if (strchr($string1, $character))
      { return true;
    }
  }
  return;
}

add_hook("ClientDetailsValidation",1,"checkuserdata");

 

 

 

This hook is available also in the official DomainRegister repository on Github.

 

 

Found this article interesting?
Subscribe to DomainRegister´s newsletter!

You can unsubscribe at any time by simply clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp s privacy practices here.

  • WHMCS, security
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

 How to add a favicon in WHMCS

To add a favicon to your WHMCS install: copy your favicon (es. myfavicon.ico) in WHMCS folder...

 How to comment in template (.tpl) files

If you need to insert a comment in a .tpl file, or comment a block of code to disable it, you...

 How to insert a Youtube video in WHMCS knowledgebase article

To insert a YouTube video in an article of the WHMCS knowledge base, you need to insert following...

 How to disable a customer to pay invoices partly with credit balance

in WHMCS if a customer has not enough credit balance for full payment of an invoice, WHMCS allows...

 How to add a cookie bar to WHMCS

In order to add a cookie bar to your own installation of WHMCS: copy somewhere on your WHMCS...