October 21, 2024
Chicago 12, Melborne City, USA
PHP

Why is my WHMCS hook not creating a ticket?


I am trying to create a ticket when a domain registration or transfer fails. Right now I’m just working on the registration failure. Here is my code:

<?php
add_hook('AfterRegistrarRegistrationFailed', 1, function($vars) {
$domainname = $vars['sld'] . $vars['tld'];
//$regerrormsg = $vars['error'];
    $command = 'OpenTicket';
    $postData = array(
        'deptid' => '3',
        'subject' => 'Domain Registration Failure: ' . $domainname. '',
        'message' => 'AUTOMATED MESSAGE: The domain registration for ' . $domainname . ' has failed. Please **do not** try to re-register this domain at this time. We have already been alerted to the issue and will be in touch to help you solve it. We appreciate your patience while we look into this. You will not have to pay for this registration again.',
        'clientid' => $vars['clientid'],
        'priority' => 'High',
        'markdown' => true,
        'preventClientClosure' => true,
);
$adminUsername="sphereadmin";
$results = localAPI($command, $postData, $adminUsername);
print_r($results);
});
?>

I’ve tried variations of this code and nothing works.

Expected behavior is it creates a ticket with these parameters for the client. Right now nothing happens. No errors in Hook Debug logs either. Totally stumped.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video