Search code examples
phpwhmcs

How to run a WHMCS hook for any one template


I want to run a hook only one template? I mean the primary navigation bar hook should be run if anyone access the WHMCS by using index.php?systpl=six Not on any other template.

Thanks.


Solution

  • Currently, WHMCS developer documentation doesn't provide a way to get the current template for menus hooks.

    But I noticed that there is a global variable that have the active template, you need to test through all pages to make sure code is working, I tested on Client Services page:

    function my_custom_navs_func() {
    
        global $inputParams;
    
        $activeTemplate = $inputParams['clientareatemplate'];
    
        if ($activeTemplate == 'six') {
    
            //Do something here!
        }
    }
    add_hook('ClientAreaNavbars', 1, 'my_custom_navs_func');