API // Inside WHMCS
How to check existing client in WHMCS by email
Native WHMCS API allows us to register clients, but not to check if certain email is already in use. So this tiny function will help you to determine do you already have this client in your DB.
Save this file into whmcs_folder/includes/api/clientexist.php
<?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); $result = select_query("tblclients", "id", array("email" => $_POST['email'])); $data = mysql_fetch_assoc($result); $result = array(); if (isset($data['id']) && $data['id'] != '') { $result["result"] = TRUE; } else { $result["result"] = FALSE; } echo json_encode($result); ?>
It returns JSON encoded answer, so dont forget to decode it back when you check the result.
Enjoy!
I want to add some “part” of the email for registered clients only, it’s possible?
some
{if $variblethat takeclientemailforclients eq $client_email}
content for registred customers only
{/if}
?