Admin Area

The following hooks are provided for Admin Area related events.

Allows returning of links for display on the client summary page in the Action Links section.

Parameters

Variable Type Notes
userid int The id of the user being displayed

Response

An array of links to be displayed.

Example Code

<?php

add_hook('AdminAreaClientSummaryActionLinks', 1, function($vars) {
    $return = [];

    if ($vars['userid'] == 1) {
        $return[] = '<a href="http://www.whmcs.com/">WHMCS</a>';
        $return[] = '<a href="http://www.enom.com/">eNom</a>';
    }

    return $return;
});

AdminAreaClientSummaryPage

Allows returning of output for display on the client summary page.

Parameters

Variable Type Notes
userid int The id of the user being displayed

Response

Return the HTML to be output on the page.

Example Code

<?php

add_hook('AdminAreaClientSummaryPage', 1, function($vars) {
    return 'This message will be output on the Client Summary page. I can add HTML here';
});

AdminAreaPage

Runs on every admin area page load. All template variables defined at the time the hook is invoked are made availble to this hook point. This can vary by page. The list below is not an exhaustive list.

Parameters

Variable Type Notes
charset string System charset setting eg. UTF-8
template string The admin template being used
pagetemplate string The template for the current page (if applicable)
adminid int The currently logged in admin user ID
admin_username string The username of the current admin user
admin_notes string The private notes for the current admin user
admin_perms array The permissions of the current admin user
addon_modules array A list of add-on modules the current admin user has access to
filename string The name of the file being called
pagetitle string The title of the current page
helplink string The documentation url for the current page
sidebar string The sidebar output
minsidebar bool Returns true if the sidebar is minimised
jquerycode string jQuery code for the current page
jscode string Javascript code for the current page
datepickerformat string The format defined for dates in the admin area
adminsonline string A list of currently online admin users
sidebarstats array Statistics relating to orders, clients, services, tickets and more

Response

Accepts a return of key/value pairs to be made available to the template layer as additional template variables.

Example Code

<?php
add_hook('AdminAreaPage', 1, function($vars) {
    $extraVariables = [];
    if ($vars['filename'] == 'index.php') {
        $extraVariables['newVariable1'] = 'thisValue';
        $extraVariables['newVariable2'] = 'thatValue';
    }
    return $extraVariables;
});

AdminAreaViewQuotePage

Executes as the quote is being viewed.

Parameters

Variable Type Notes
quoteid int

Response

An array of HTML to display on the View Quote page

Example Code

<?php

add_hook('AdminAreaViewQuotePage', 1, function($vars) {
    return [
        'This will be displayed on the Admin Area View Quote Page',
        'This will also be displayed',
    ];
});

AdminClientDomainsTabFields

Executes when a domain is being viewed in the Admin area.

Parameters

Variable Type Notes
id int the id of the domain being loaded

Response

An array of key -> value parameters to output additional fields as required.

Example Code

<?php

add_hook('AdminClientDomainsTabFields', 1, function($vars) {
    return [
        'Additional Field 1' => '<input type="text" name="additionalFieldOne" class="form-control input-150" />',
        'Additional Field 2' => '<input type="text" name="additionalFieldTwo" class="form-control input-150" />',
    ];
});

AdminClientDomainsTabFieldsSave

Executes when the Domains tab in the Admin area is being saved. Receives all the $_REQUEST parameters as variables.

Parameters

Variable Type Notes
No input parameters for this hook point.

Response

No response supported

Example Code

<?php

//Obtain the values defined in the AdminClientProfileTabFields hook point and save them as required
add_hook('AdminClientDomainsTabFieldsSave', 1, function($vars) {
    $domainId = $vars['id'];
    $additionalFieldOne = App::getFromRequest('additionalFieldOne');
    $additionalFieldTwo = App::getFromRequest('additionalFieldTwo');

    //Save the data here
});

AdminClientFileUpload

Executes as a client file is being uploaded from the Client Summary.

Parameters

Variable Type Notes
userid int
title string
filename string The filename as stored on the server
origfilename string The original filename
adminonly bool

Response

No response supported

Example Code

<?php
add_hook('AdminClientFileUpload', 1, function($vars) {
    // Perform hook code here...
});

AdminClientProfileTabFields

Executes when a client profile is being viewed in the Admin area.

Parameters

Variable Type Notes
userid int
uuid string
firstname string
lastname string
companyname string
email string
address1 string
address2 string
city string
state string
postcode string
country string
phonenumber string
password string The encrypted password for the user
currency int The id of the currency
notes string
status string
taxexempt bool
latefeeoveride bool
overideduenotices bool
separateinvoices bool
disableautocc bool
emailoptout bool
overrideautoclose bool
language string
billingcid int
securityqid int
securityqans string The encrypted security question answer
groupid int The id of the client group
allow_sso bool Is Single Sign on enabled for the client?
olddata array An array of the previous contact information
authmodule string The 2Factor Auth Module enabled for the user
authdata string The 2Factor Auth Data for the user
email_verified bool

Response

An array of key -> value parameters to output additional fields as required.

Example Code

<?php

add_hook('AdminClientProfileTabFields', 1, function($vars) {
    return [
        'Additional Field 1' => '<input type="text" name="additionalFieldOne" class="form-control input-150" />',
        'Additional Field 2' => '<input type="text" name="additionalFieldTwo" class="form-control input-150" />',
    ];
});

AdminClientProfileTabFieldsSave

Executes when the Profile in the Admin area is being saved. Receives all the $_REQUEST parameters as variables.

Parameters

Variable Type Notes
No input parameters for this hook point.

Response

No response supported

Example Code

<?php

//Obtain the values defined in the AdminClientProfileTabFields hook point and save them as required
add_hook('AdminClientProfileTabFieldsSave', 1, function($vars) {
    $userId = App::getFromRequest('userid');
    $additionalFieldOne = App::getFromRequest('additionalFieldOne');
    $additionalFieldTwo = App::getFromRequest('additionalFieldTwo');

    //Save the data here
});

AdminClientServicesTabFields

Executes when a service is being viewed in the Admin area.

Parameters

Variable Type Notes
id int the id of the service being loaded

Response

An array of key -> value parameters to output additional fields as required.

Example Code

<?php
add_hook('AdminClientServicesTabFields', 1, function($vars) {
    // Perform hook code here...
});

AdminClientServicesTabFieldsSave

Executes when the Services tab in the Admin area is being saved. Receives all the $_REQUEST parameters as variables.

Parameters

Variable Type Notes
No input parameters for this hook point.

Response

No response supported

Example Code

<?php
add_hook('AdminClientServicesTabFieldsSave', 1, function($vars) {
    // Perform hook code here...
});

AdminHomepage

Allows returning of output for display on the admin homepage

Parameters

Variable Type Notes
No input parameters for this hook point.

Response

Return the HTML to be output on the page.

Example Code

<?php
add_hook('AdminHomepage', 1, function($vars) {
    return 'This message will appear on the Admin Homepage';
});

AdminLogin

Executes post successful authentication of an admin user

Parameters

Variable Type Notes
adminid int
username string

Response

No response supported

Example Code

<?php
add_hook('AdminLogin', 1, function($vars) {
    // Perform hook code here...
});

AdminLogout

Executes on Admin log out

Parameters

Variable Type Notes
adminid int

Response

No response supported

Example Code

<?php
add_hook('AdminLogout', 1, function($vars) {
    // Perform hook code here...
});

AdminProductConfigFields

Executes as a product is being edited.

Parameters

Variable Type Notes
pid int

Response

An array of key -> value pairs to display on the Other tab.

Example Code

<?php
add_hook('AdminProductConfigFields', 1, function($vars) {
    // Perform hook code here...
});

AdminProductConfigFieldsSave

Executes as a product is being saved. Access The Request variables to save custom config fields.

Parameters

Variable Type Notes
pid int

Response

No response supported

Example Code

<?php
add_hook('AdminProductConfigFieldsSave', 1, function($vars) {
    // Perform hook code here...
});

AdminServiceEdit

Executes as the service is being saved, after any changes have been made.

Parameters

Variable Type Notes
userid int
serviceid int

Response

No response supported

Example Code

<?php
add_hook('AdminServiceEdit', 1, function($vars) {
    // Perform hook code here...
});

AuthAdmin

Executes during Admin form-based password authentication

Parameters

Variable Type Notes
userInput string The user-provided password value
\WHMCS\User\Admin The admin attempting to authenticate

Response

TRUE on success FALSE on failure

Example Code

<?php

// EXAMPLE SERVICE CLASS ONLY; NOT VALID FOR PRODUCTION
class MyAuthService
{
    public static function getAdminHash($adminUniqueId)
    {
        $hashes = [
            '[email protected]' => '$2y$10$VKrc/52lKfl1FZWFTsmUpeORk18adQAulXlv634q6wkMseBDGbilO'
        ];

        if (array_key_exists($adminUniqueId, $hashes)) {
            return $hashes[$adminUniqueId];
        }

        return null;
    }
}

add_hook(
    'AuthAdmin',
    0,
    function ($userInput, WHMCS\User\Admin $admin) {
        $adminUniqueId = $admin->email;
        $adminHash = MyAuthService::getAdminHash($adminUniqueId);
        if (!$adminHash) {
            return false;
        }

        return password_verify($userInput, $adminHash);
    }
);

AuthAdminApi

Executes during Admin API password authentication

Parameters

Variable Type Notes
userInput string The user-provided password value
\WHMCS\User\Admin The admin attempting to authenticate

Response

TRUE on success FALSE on failure

Example Code

<?php
add_hook('AuthAdminApi', 1, function($vars) {
    // Perform hook code here...
});

InvoiceCreationAdminArea

Executes when an invoice is first created by an admin user. The invoice has not been delivered to the client at this point.

Parameters

Variable Type Notes
source string
user string int
invoiceid int The invoice ID that was created
status string The status of the new invoice

Response

No response supported

Example Code

<?php
add_hook('InvoiceCreationAdminArea', 1, function($vars) {
    // Perform hook code here...
});

PreAdminServiceEdit

Executes as the service is being saved, before any changes have been made.

Parameters

Variable Type Notes
serviceid int

Response

No response supported

Example Code

<?php
add_hook('PreAdminServiceEdit', 1, function($vars) {
    // Perform hook code here...
});