It is not always easy to determine which PHP variables are available and defined within a given WHMCS hook: the available documentation is often quite laconic and imprecise, and to discover them you sometimes have to resort to experience or proceed by random attempts.
However, a trick is available to determine all PHP variables defined and available: just insert the following code inside our hook:

echo "<pre>";
   print_r(get_defined_vars());
echo "</pre>";

So, an example hook implementing this function could look like this:

<?php
add_hook('ClientAreaPageViewTicket', 1, function($vars) {
echo "<pre>";
   print_r(get_defined_vars());
echo "</pre>";
});

This function will return the value of all PHP variables defined within the hook; the values will be shown on the screen, therefore it is recommended to use it only and exclusively in a test environment!!!

The output will be formatted and easily readable, but huge (hundreds of rows): so it is advisable to copy-paste it into your text editor to examine it and identify the elements of your interest.

 

 

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...