Skip to content

Contact

The following hooks are provided for Contact related events.

ContactAdd

Executes as a contact is being added to WHMCS.

Parameters

VariableTypeNotes
useridint
contactidint
firstnamestring
lastnamestring
companynamestring
emailstring
address1string
address2string
citystring
statestring
postcodestring
countrystring
phonenumberstring
tax_idstring
generalemailsbool
productemailsbool
domainemailsbool
invoiceemailsbool
supportemailsbool
affiliateemailsbool

Response

No response supported

Example Code

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

ContactDelete

Executes on Contact Delete after the contact has been removed.

Parameters

VariableTypeNotes
useridint
contactidint

Response

No response supported

Example Code

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

ContactDetailsValidation

Executes on validation of contact details.

Parameters

VariableTypeNotes
N/AarrayThe POSTed variables

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('ContactDetailsValidation', 1, function($vars) {
    return [
        'Error message feedback error 1',
        'Error message feedback error 2',
    ];
});

ContactEdit

Runs when a contact is edited.

Parameters

VariableTypeNotes
useridint
contactidint
firstnamestring
lastnamestring
companynamestring
emailstring
address1string
address2string
citystring
statestring
postcodestring
countrystring
phonenumberstring
tax_idstring
domainemailsbool
generalemailsbool
invoiceemailsbool
productemailsbool
supportemailsbool
affiliateemailsbool
olddataarrayAn array of the previous contact information

Response

No response supported

Example Code

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