The WHMCS hook documentation is quite minimal and does not comprehensively list all the variables passed by the system to each hook. As a result, developers often have to guess or take inspiration from code written by others (who likely guessed before us, until they discovered the right variable...).

However, there’s a very simple way to discover and document all the variables passed to a specific hook. For example, to inspect the PreRegistrarRegisterDomain hook, you can simply create and run the following hook:

 
add_hook('PreRegistrarRegisterDomain', 1, function($vars) {
    $results = logActivity(json_encode($vars),0);
});

The result will be a line in the WHMCS log file with a string in JSON format, containing all available variables and their corresponding values.

NOTES:

  • The log entries generated this way can be quite large and heavy; it’s recommended to delete or disable the hook right after obtaining the needed information.

  • The single-line JSON format in the log file is not very readable; for better readability, it’s a good idea to paste it into a tool like https://jsonformatter.org/json-parser.

  • The line of code  logActivity(json_encode($vars), 0); can also be useful within any hook code for debugging purposes, to discover the exact values of the variables passed to a specific hook.

Found this article interesting?
Subscribe to DomainRegister´s newsletter!

You can unsubscribe at any time by simply clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp s privacy practices here.

  • WHMCS
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

 How to add a favicon in WHMCS

To add a favicon to your WHMCS install: copy your favicon (es. myfavicon.ico) in WHMCS folder...

 How to comment in template (.tpl) files

If you need to insert a comment in a .tpl file, or comment a block of code to disable it, you...

 How to insert a Youtube video in WHMCS knowledgebase article

To insert a YouTube video in an article of the WHMCS knowledge base, you need to insert following...

 How to disable a customer to pay invoices partly with credit balance

in WHMCS if a customer has not enough credit balance for full payment of an invoice, WHMCS allows...

 How to add a cookie bar to WHMCS

In order to add a cookie bar to your own installation of WHMCS: copy somewhere on your WHMCS...