notification on admin login to WHMCS

Have you ever wanted to receive a notification on admin login to WHMCS? Well, this WHMCS hook does just this. It’s fairly straightforward, just copy and paste the following code into a file in  your whmcs/includes/hooks directory


/* admin login notification for WHMCS
retooled for v6
04-20-2016 - UPdated to use Capsule

use Illuminate\Database\Capsule\Manager as Capsule;

function hook_email_adminonlogin($vars)
$adminid = $vars['adminid'];
if (!filter_var($adminid, FILTER_VALIDATE_INT))

$admininfo = Capsule::table('tbladmins') ->select('username') ->where('id', '=', $adminid)->get();
foreach ($admininfo as $adminrow)
$ausername = $adminrow->username;

$subject = "[WHMCS] Admin login notification";
$body = "WHMCS Admin Login Notification for " . $ausername . " from " . $ip;

/* calling the local api to do the job */
$command = "sendadminemail";
$adminuser = "CHANGEME";
$values["type"] = "system";
$values["customsubject"] = $subject;
$values["custommessage"] = $body;

$results = localAPI($command,$values,$adminuser);


Now, you will receive a notification on admin login to WHMCS , and you’re good to go!


You’ll have to change the $adminuser variable to one of your admin users  that has API access (usually a full admin user).

As always, if you have any questions or concerns, please do contact us. We’re always here and ready to help . If you need custom development done, we’re absolutely here to help with that as well! Just drop us a line.