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.
| Variable | Type | Notes |
|---|---|---|
| userid | int | The id of the user being displayed |
An array of links to be displayed.
<?php
add_hook('AdminAreaClientSummaryActionLinks', 1, function($vars) {
$return = [];
if ($vars['userid'] == 1) {
$return[] = '<a href="https://www.whmcs.com/">WHMCS</a>';
$return[] = '<a href="https://www.enom.com/">eNom</a>';
}
return $return;
});Allows returning of output for display on the client summary page.
| Variable | Type | Notes |
|---|---|---|
| userid | int | The id of the user being displayed |
Return the HTML to be output on the page.
<?php
add_hook('AdminAreaClientSummaryPage', 1, function($vars) {
return 'This message will be output on the Client Summary page. I can add HTML here';
});Runs on every admin area page load. All template variables defined at the time the hook is invoked are made available to this hook point. This can vary by page. The list below is not an exhaustive list.
| 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 |
Accepts a return of key/value pairs to be made available to the template layer as additional template variables.
<?php
add_hook('AdminAreaPage', 1, function($vars) {
$extraVariables = [];
if ($vars['filename'] == 'index.php') {
$extraVariables['newVariable1'] = 'thisValue';
$extraVariables['newVariable2'] = 'thatValue';
}
return $extraVariables;
});Executes as the quote is being viewed.
| Variable | Type | Notes |
|---|---|---|
| quoteid | int |
Return the HTML to display on the View Quote page.
<?php
add_hook('AdminAreaViewQuotePage', 1, function($vars) {
return 'This will be displayed on the Admin Area View Quote Page. I can add HTML here';
});Executes when a domain is being viewed in the Admin area.
| Variable | Type | Notes |
|---|---|---|
| id | int | the id of the domain being loaded |
An array of key -> value parameters to output additional fields as required.
<?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" />',
];
});Executes when the Domains tab in the Admin area is being saved. Receives all the $_REQUEST parameters as variables.
| Variable | Type | Notes |
|---|---|---|
| No input parameters for this hook point. |
No response supported
<?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 = $_REQUEST['additionalFieldOne'];
$additionalFieldTwo = $_REQUEST['additionalFieldTwo'];
//Save the data here
});Executes as a client file is being uploaded from the Client Summary.
| Variable | Type | Notes |
|---|---|---|
| userid | int | |
| title | string | |
| filename | string | The filename as stored on the server |
| origfilename | string | The original filename |
| adminonly | bool |
No response supported
<?php
add_hook('AdminClientFileUpload', 1, function($vars) {
// Perform hook code here...
});Executes when a client profile is being viewed in the Admin area.
| Variable | Type | Notes |
|---|---|---|
| userid | int | |
| uuid | string | |
| firstname | string | |
| lastname | string | |
| companyname | string | |
| 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 | |
| marketing_emails_opt_in | bool | |
| overrideautoclose | bool | |
| language | string | |
| billingcid | int | |
| 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 |
An array of key -> value parameters to output additional fields as required.
<?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" />',
];
});Executes when the Profile in the Admin area is being saved. Receives all the $_REQUEST parameters as variables.
| Variable | Type | Notes |
|---|---|---|
| No input parameters for this hook point. |
No response supported
<?php
//Obtain the values defined in the AdminClientProfileTabFields hook point and save them as required
add_hook('AdminClientProfileTabFieldsSave', 1, function($vars) {
$userId = $vars['userid'];
$additionalFieldOne = $_REQUEST['additionalFieldOne'];
$additionalFieldTwo = $_REQUEST['additionalFieldTwo'];
//Save the data here
});Executes when a service is being viewed in the Admin area.
| Variable | Type | Notes |
|---|---|---|
| id | int | the id of the service being loaded |
An array of key -> value parameters to output additional fields as required.
<?php
add_hook('AdminClientServicesTabFields', 1, function($vars) {
// Perform hook code here...
});Executes when the Services tab in the Admin area is being saved. Receives all the $_REQUEST parameters as variables.
| Variable | Type | Notes |
|---|---|---|
| No input parameters for this hook point. |
No response supported
<?php
add_hook('AdminClientServicesTabFieldsSave', 1, function($vars) {
// Perform hook code here...
});Allows returning of output for display on the admin homepage
| Variable | Type | Notes |
|---|---|---|
| No input parameters for this hook point. |
Return the HTML to be output on the page.
<?php
add_hook('AdminHomepage', 1, function($vars) {
return 'This message will appear on the Admin Homepage';
});Executes post successful authentication of an admin user
| Variable | Type | Notes |
|---|---|---|
| adminid | int | |
| username | string |
No response supported
<?php
add_hook('AdminLogin', 1, function($vars) {
// Perform hook code here...
});Executes on Admin log out
| Variable | Type | Notes |
|---|---|---|
| adminid | int |
No response supported
<?php
add_hook('AdminLogout', 1, function($vars) {
// Perform hook code here...
});Executes as the Create New Addon page is loaded.
| Variable | Type | Notes |
|---|---|---|
| No input parameters for this hook point. |
array of values used for the creation of predefined addon panels. See example for array structure.
<?php
/**
* Setting the 'icontype' value to 'fa' allows for the use of Font Awesome icons.
*/
add_hook('AdminPredefinedAddons', 1, function () {
return [
[
'module' => 'yourmodule',
'icontype' => 'fa',
'iconvalue' => 'fad fa-cube',
'labeltype' => 'success',
'labelvalue' => 'Sample Label',
'paneltitle' => 'Sample Title',
'paneldescription' => 'Description to be displayed in the Predefined Addon panel.',
'addonname' => 'On addon creation, this value will be used as the addon name.',
'addondescription' => 'On addon creation, this value will be used as the addon description.',
'welcomeemail' => 'Hosting Account Welcome Email',
'featureaddon' => 'Name of feature addon as stored in the database.',
],
];
});
/**
* Alternatively the 'icontype' value can be set to 'url' to allow for the use of URLs and file paths.
*/
add_hook('AdminPredefinedAddons', 1, function () {
return [
[
'module' => 'yourmodule',
'icontype' => 'url',
'iconvalue' => 'https://www.whmcs.com/images/logo.png',
'paneltitle' => 'Sample Title',
'paneldescription' => 'Description to be displayed in the Predefined Addon panel.',
'addonname' => 'On addon creation, this value will be used as the addon name.',
'addondescription' => 'On addon creation, this value will be used as the addon description.',
'featureaddon' => 'Name of feature addon as stored in the database.',
],
];
});Executes as a product is being edited.
| Variable | Type | Notes |
|---|---|---|
| pid | int |
An array of key -> value pairs to display on the Other tab.
<?php
add_hook('AdminProductConfigFields', 1, function($vars) {
// Perform hook code here...
});Executes as a product is being saved. Access The Request variables to save custom config fields.
| Variable | Type | Notes |
|---|---|---|
| pid | int |
No response supported
<?php
add_hook('AdminProductConfigFieldsSave', 1, function($vars) {
// Perform hook code here...
});Executes when the Service has been edited by an Admin. After the changes have been made.
| Variable | Type | Notes |
|---|---|---|
| userid | int | |
| serviceid | int |
No response supported
<?php
add_hook('AdminServiceEdit', 1, function($vars) {
// Perform hook code here...
});Executes during Admin form-based password authentication
| Variable | Type | Notes |
|---|---|---|
| userInput | string | The user-provided password value |
| \WHMCS\User\Admin | The admin attempting to authenticate |
TRUE on success FALSE on failure
<?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);
}
);| Variable | Type | Notes |
|---|---|---|
| $userInput | ||
| $admin |
No response supported
<?php
add_hook('AuthAdminApi', 1, function($vars) {
// Perform hook code here...
});Executes as an invoice is being created in the admin area
| Variable | Type | Notes |
|---|---|---|
| source | string | When the invoice is being created |
| user | int | string |
| invoiceid | int | The id of the newly created invoice |
| status | string | The status of the newly created invoice |
No response supported
<?php
add_hook('InvoiceCreationAdminArea', 1, function($vars) {
// Perform hook code here...
});Executes as the service is being saved, before any changes have been made.
| Variable | Type | Notes |
|---|---|---|
| serviceid | int |
No response supported
<?php
add_hook('PreAdminServiceEdit', 1, function($vars) {
// Perform hook code here...
});Executes as the order details page is being displayed
| Variable | Type | Notes |
|---|---|---|
| orderid | int | |
| ordernum | int | |
| userid | int | |
| amount | float | |
| paymentmethod | string | |
| invoiceid | int | |
| string | status |
No response supported
<?php
add_hook('ViewOrderDetailsPage', 1, function($vars) {
// Perform hook code here...
});