Skip to content

Ticket

The following hooks are provided for Ticket related events.

AdminAreaViewTicketPage

Executes when an admin views a support ticket within the admin area.

Parameters

VariableTypeNotes
ticketidint

Response

Returned HTML will be output to the page.

Example Code

<?php

use WHMCS\Session;
use WHMCS\Ticket\Watchers;

add_hook('AdminAreaViewTicketPage', 1, function($vars) {
    $return = '';
    $adminId = Session::get('adminid');

    $adminWatchingTickets = Watchers::byAdmin($adminId)->pluck('ticket_id')->toArray();

    if (in_array($vars['ticketid'], $adminWatchingTickets)) {
        $return = '<div class="alert alert-info" role="alert">You are watching this ticket</div>';
    }
    return $return;
});

AdminAreaViewTicketPageSidebar

Executes when an admin views a support ticket within the admin area.

Parameters

VariableTypeNotes
ticketidint

Response

Returned HTML will be output to the sidebar.

Example Code

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

AdminSupportTicketPagePreTickets

Executes prior to aggregation and output of the support tickets listing page within the admin area.

Parameters

VariableTypeNotes
No input parameters for this hook point.

Response

Returned HTML will be output to the page.

Example Code

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

ClientAreaPageSubmitTicket

Executes on the client area ticket submission page and accepts a return of key/value pairs to be made available as additional Smarty template parameters. Input parameters include all currently defined template variables. The following is a list of template variables common to all pages. Additional variables will vary depending upon the page being rendered.

Parameters

VariableTypeNotes
companynamestring
logostring
systemurlstring
charsetstring
pagetitlestring
filenamestring
templatestring
languagestring
LANGarrayActive language translation strings
todaysdatestringHuman friendly formatted version of todays date
date_daystringCurrent day of the month
date_monthstringCurrent month
date_yearstringCurrent year
WEB_ROOTstringThe web path to the WHMCS doc root
BASE_PATH_CSSstring
BASE_PATH_JSstring
BASE_PATH_FONTSstring
BASE_PATH_IMGstring
tokenstringCSRF token value
servedOverSslboolTrue if page was loaded via https://

Response

A key/value pair array of additional template variables to define.

Example Code

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

ClientAreaPageSupportTickets

Executes on the client area support tickets overview page and accepts a return of key/value pairs to be made available as additional Smarty template parameters. Input parameters include all currently defined template variables. The following is a list of template variables common to all pages. Additional variables will vary depending upon the page being rendered.

Parameters

VariableTypeNotes
companynamestring
logostring
systemurlstring
charsetstring
pagetitlestring
filenamestring
templatestring
languagestring
LANGarrayActive language translation strings
todaysdatestringHuman friendly formatted version of todays date
date_daystringCurrent day of the month
date_monthstringCurrent month
date_yearstringCurrent year
WEB_ROOTstringThe web path to the WHMCS doc root
BASE_PATH_CSSstring
BASE_PATH_JSstring
BASE_PATH_FONTSstring
BASE_PATH_IMGstring
tokenstringCSRF token value
servedOverSslboolTrue if page was loaded via https://

Response

A key/value pair array of additional template variables to define.

Example Code

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

ClientAreaPageViewTicket

Executes on the client area view ticket page and accepts a return of key/value pairs to be made available as additional Smarty template parameters. Input parameters include all currently defined template variables. The following is a list of template variables common to all pages. Additional variables will vary depending upon the page being rendered.

Parameters

VariableTypeNotes
companynamestring
logostring
systemurlstring
charsetstring
pagetitlestring
filenamestring
templatestring
languagestring
LANGarrayActive language translation strings
todaysdatestringHuman friendly formatted version of todays date
date_daystringCurrent day of the month
date_monthstringCurrent month
date_yearstringCurrent year
WEB_ROOTstringThe web path to the WHMCS doc root
BASE_PATH_CSSstring
BASE_PATH_JSstring
BASE_PATH_FONTSstring
BASE_PATH_IMGstring
tokenstringCSRF token value
servedOverSslboolTrue if page was loaded via https://

Response

A key/value pair array of additional template variables to define.

Example Code

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

SubmitTicketAnswerSuggestions

Executes prior to looking up knowledgebase article suggestions related to the message body of a ticket. Can be used to override the default knowledgebase lookup. If fewer than 5 results are returned, WHMCS will search the knowldebase and add its own results to the output.

Parameters

VariableTypeNotes
textstringThe message body

Response

An array of knowledgebase article IDs.

Example Code

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

TicketAddNote

Executes when a ticket note is added.

Parameters

VariableTypeNotes
ticketidint
messagestring
adminidint
attachmentsstring

Response

No response supported

Example Code

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

TicketAdminReply

Executes when a reply is added to a ticket by an admin user.

Parameters

VariableTypeNotes
ticketidint
replyidint
deptidint
deptnamestring
subjectstring
messagestring
prioritystring
adminstringAdmin user display name
statusstringTicket status post reply

Response

No response supported

Example Code

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

TicketClose

Executes when a ticket is closed.

Parameters

VariableTypeNotes
ticketidint

Response

No response supported

Example Code

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

TicketDelete

Executes when a ticket is deleted.

Parameters

VariableTypeNotes
ticketIdint
adminIdintThe admin ID who initiated the action

Response

No response supported

Example Code

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

TicketDeleteReply

Executes when a ticket reply is deleted.

Parameters

VariableTypeNotes
ticketIdint
replyIdint
adminIdintThe admin ID who initiated the action

Response

No response supported

Example Code

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

TicketDepartmentChange

Executes as a ticket department is changed

Parameters

VariableTypeNotes
ticketidint
deptidint
deptnameint

Response

No response supported

Example Code

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

TicketFlagged

Executes as a ticket is flagged

Parameters

VariableTypeNotes
ticketidint
adminidint
adminnamestring

Response

No response supported

Example Code

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

TicketMerge

Executes when tickets are merged into each other.

Parameters

VariableTypeNotes
mergedTicketIdsarrayThe ticket IDs to be merged.
masterTicketIdintThe ticket ID of the ticket containing the merged tickets.

Response

No response supported

Example Code

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

TicketOpen

Executes when a ticket is opened by an end user.

Parameters

VariableTypeNotes
ticketidint
ticketmaskstring
useridint
deptidint
deptnamestring
subjectstring
messagestring
prioritystring

Response

No response supported

Example Code

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

TicketOpenAdmin

Executes when a ticket is opened by an admin user.

Parameters

VariableTypeNotes
ticketidint
ticketmaskstring
useridint
deptidint
deptnamestring
subjectstring
messagestring
prioritystring

Response

No response supported

Example Code

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

TicketOpenValidation

Executes when an end user provides data for a new ticket submission.

Parameters

VariableTypeNotes
clientIdintClient ID if associated with a client
contactIdintContact ID if associated with a contact
namestringName from email envelope if not a client
emailstringEmail from email envelope if not a client
isAdminboolTRUE if initiated within Admin Area or via API with input $admin=TRUE
departmentIdint
subjectstring
messagestring
prioritystring
relatedServicestring
customfieldsarray

Response

A string to be used as a singular Validation Error.

Example Code

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

TicketPiping

Executes when a ticket is being imported via email.

Parameters

VariableTypeNotes
tostring
ccarray
namestring
emailstring
subjectstring
bodystring
attachmentsstring

Response

Return skipProcessing=true to abort importing of the given email.

Example Code

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

TicketPriorityChange

Executes when a ticket priority is changed

Parameters

VariableTypeNotes
ticketidint
prioritystring

Response

No response supported

Example Code

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

TicketSplit

Executes when ticket replies are being split into a new ticket.

Parameters

VariableTypeNotes
originalTicketIdintThe Ticket ID that replies originally resided within.
newTicketIDintThe new Ticket ID for the split replies.

Response

No response supported

Example Code

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

TicketStatusChange

Executes as a ticket status is changed manually by an admin.

Parameters

VariableTypeNotes
adminidint
statusstring
ticketidint

Response

No response supported

Example Code

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

TicketSubjectChange

Executes when a ticket subject is changed. The 'subject' variable now contains the new subject.

Parameters

VariableTypeNotes
ticketidint
subjectstring

Response

No response supported

Example Code

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

TicketUserReply

Executes when a reply is added to a ticket by an end user.

Parameters

VariableTypeNotes
ticketidint
replyidint
useridint
deptidint
deptnamestring
subjectstring
messagestring
prioritystring
statusstringTicket status post reply

Response

No response supported

Example Code

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

TransliterateTicketText

Invoked when a ticket is imported from email.

Parameters

VariableTypeNotes
subjectstringThe message subject
messagestringThe message body

Response

Override the global variables $subject and $message to manipulate.

Example Code

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