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!

Little about me:

Im professional web developer. Love to work with PHP-driven projects. WHMCS seems to me the way to share my knowledges. Some of you may be interested in hiring me - drop me a line or take a look at my Odesk profile

1 Comment + Add Comment

  • 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}
    ?

Leave a comment to Shalom Burla