Skip to content

Client

The following hooks are provided for Client related events.

AfterClientMerge

Executes after a client merge has completed.

Parameters

VariableTypeNotes
toUserIDintThe id of the user being merged into.
fromUserIDintThe id of the user being merged from.

Response

No response supported

Example Code

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

ClientAdd

Executes as a client is being added to WHMCS.

Parameters

VariableTypeNotes
client_idintThe id of the client that has been added
user_idintThe user id the client belongs to
useridintThe id of the client that has been added
firstnamestring
lastnamestring
companynamestring
emailstring
address1string
address2string
citystring
statestring
postcodestring
countrystring
phonenumberstring
tax_idstring
passwordstring
customFieldsarray
taxexemptbool
latefeeoveridebool
overideduenoticesbool
separateinvoicesbool
disableautoccbool
emailoptoutbool
marketing_emails_opt_inbool
overrideautoclosebool
notesstring
groupidint

Response

No response supported

Example Code

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

ClientAlert

Executes when Client Alerts are being defined

Parameters

VariableTypeNotes
N/A\WHMCS\User\ClientThe client model

Response

Return a new alert object for rendering.

Example Code

<?php

use WHMCS\User\Alert;

add_hook('ClientAlert', 1, function($client) {
    $firstName = $client->firstName;
    $lastName = $client->lastName;
    return new Alert(
        "This is a test notification for {$firstName} {$lastName}",
        'info' //see http://getbootstrap.com/components/#alerts
    );
});

ClientChangePassword

Executed when a change of password occurs for a client.

Parameters

VariableTypeNotes
useridintThe ID of the Client being updated
passwordstringThe new password

Response

No response supported

Example Code

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

ClientClose

Executes after a client has been closed

Parameters

VariableTypeNotes
useridint

Response

No response supported

Example Code

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

ClientDelete

DEPRECATED (since 8.0.0-beta.1): See PreDeleteClient hook as replacement.

Parameters

VariableTypeNotes
useridint

Response

No response supported

Example Code

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

ClientDetailsValidation

Executes before adding a client or updating a client through the Admin or Client area.

Parameters

VariableTypeNotes
firstnamestringThe client's firstname
lastnamestringThe client's lastname
companynamestringThe client's company, if entered
emailstringThe client's email
address1stringThe client's address1
address2stringThe client's address2, if entered
citystringThe client's city
statestringThe client's state
postcodestringThe client's postcode/zipcode
countrystringThe client's country (2 character code)
phonenumberstringThe client's phone number
tax_idstringThe client's tax ID
paymentmethodstringIf selected, the client's default payment method
customfieldstringAn array of Key => Value pairs
securityqidintOnly from Admin Area or when registering
securityqansstringOnly from Admin Area or when registering

Response

Return accepts both a string or an array. Use a string for single error message or an array of strings for multiple error messages.

Example Code

<?php

add_hook('ClientDetailsValidation', 1, function($vars) {
    return [
        'Error message feedback error 1',
        'Error message feedback error 2',
    ];
});

ClientEdit

Executes when a client is edited through the Client Area, Admin Area, or API.

Parameters

VariableTypeNotes
useridint
uuidstring
firstnamestring
lastnamestring
companynamestring
emailstring
address1string
address2string
citystring
statestring
postcodestring
countrystringTwo-letter ISO code.
phonenumberstring
currencyintThe id of the currency
notesstring
statusstring
taxexemptbool
latefeeoverideboolUsed to prevent overdue invoices from including late fees.
overideduenoticesboolUsed to disable overdue email notices for clients.
separateinvoicesboolPrevent items with the same due date and payment method from being grouped into a single invoice.
disableautoccboolPrevent invoices that are due via a merchant gateway from being automatically attempted for capture.
emailoptoutboolPrevent emails sent via the Email Campaigns (formerly mass mail) or Email Marketer tools.
marketing_emails_opt_inbool
overrideautoclosebool
languagestring
billingcidintThe main contact for billing-related items.
groupidintThe id of the client group
allow_ssoboolWhether Single Sign-On is enabled for the client.
olddataarrayAn array of the previous contact information
authmodulestringThe Two-Factor Authentication module enabled for the user.
authdatastringThe Two-Factor Authentication data for the user.
email_verifiedboolWhether the client has verified their email address.
isOptedInToMarketingEmailsbool
email_preferences[affiliate]boolReceives affiliate communications.
email_preferences[domain]boolWhether the client receives registration or transfer confirmations and renewal notices.
email_preferences[general]boolWhether the client receives account-related email.
email_preferences[invoices]boolWhether the client receives new invoices, reminders, and overdue notices.
email_preferences[product]boolReceives Welcome Emails, Suspension & Other Lifecycle Notifications.
email_preferences[support]boolReceives CC of all support ticket communications.

Response

No response supported

Example Code

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

PreDeleteClient

Executes immediately before a client is deleted

Parameters

VariableTypeNotes
useridint

Response

No response supported

Example Code

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