How to Debug Smarty Templates Safely in a WHMCS Production Environment
When developing or troubleshooting a WHMCS Smarty template, the {debug} function can be extremely useful. It opens the Smarty Debug Console, where you can inspect the variables available to the current template and their values.
However, using {debug} directly in a production WHMCS installation is not recommended, because the debug console may also be displayed to regular visitors and customers.
Fortunately, WHMCS provides a simple way to restrict Smarty debugging to logged-in administrators.
Enable Smarty Debugging Only for WHMCS Administrators
First, log in to your WHMCS administration area and keep your administrator session open.
Then edit the .tpl file you want to troubleshoot and insert the following Smarty code:
{if $adminLoggedIn}
{debug}
{/if}
Now access the page that uses the template you are debugging.
If you are currently logged in as a WHMCS administrator, Smarty will open the Debug Console and display the variables available to that template.
Regular customers and visitors will not see the debug console.
Why Use $adminLoggedIn?
The $adminLoggedIn Smarty variable allows the template to determine whether the current visitor has an active WHMCS administrator session.
Instead of adding:
{debug}
which could expose debugging information to other visitors, wrapping it inside:
{if $adminLoggedIn}
{debug}
{/if}
limits the debug output to administrators.
This makes it particularly useful when you need to debug a WHMCS Smarty template on a live production website without intentionally displaying the Smarty Debug Console to normal users.
Important Security Note
The Smarty Debug Console can expose a significant amount of information about the variables passed to a template. Depending on the page, this information may include configuration values, customer-related data, URLs, IDs, or other internal information.
For this reason, you should never leave an unrestricted {debug} statement inside a template on a production WHMCS installation.
Even when using the $adminLoggedIn condition, it is good practice to remove the debugging code once troubleshooting is complete.
Quick Example
For temporary debugging of a WHMCS template:
{if $adminLoggedIn}
{debug}
{/if}
Log in to WHMCS as an administrator, visit the page you want to troubleshoot, inspect the Smarty variables in the Debug Console, and remove the code when you have finished.
This provides a simple and convenient way to debug Smarty variables in WHMCS while working on a production environment, without displaying the debug console to regular website visitors.