• Skip to main content
  • Skip to primary sidebar

xfpoint

XenForo Resource Site with Tips, Tricks and Hacks

  • Home
  • About
  • Glossary
  • Guides
  • Tutorials
  • Add-ons
  • Contact
You are here: Home / Tutorials / How to Enable Debug Mode in XenForo Only for Admins

How to Enable Debug Mode in XenForo Only for Admins

April 6, 2017 by Shabbir Bhimani

What is Debug Mode in XenForo?

Debug mode as the name suggest opens up an option to debug issues related to page loads time with the explanation of all the queries executed in rendering the output. It can immensely help to optimize SQL queries.

And helps in creating a XenForo add-ons with an extra development tabs under the admin area.

And if you don’t have the debug mode enabled, you may not be able to edit the master templates, admin templates or even edit the template modifications from other addons and can only enable/disable each template modifications.

How to Enable Debug Mode?

Enabling debug mode in XenForo is very simple and all you have to do is add the following line of code in the config.php file under the library folder of the forum root directory.

<?php
//* Do NOT include the opening php tag above. Copy the code shown below.
$config['debug'] = true;
view raw config.php hosted with ❤ by GitHub

Note: This may be good for a development environment or staging environment but it may not be ideal to enable debug mode on a live site for everybody.

Addon to Enable Debug Mode

If you aren’t comfortable adding that line of code in the config.php file, there is this addon that can do exactly the same thing for you.

Now clicking the checkbox is good enough to enable the debug mode.

On a live site, only for few minutes, enabling debug mode via an addon is convenient instead of opening up an FTP program, browse to the library folder to locate the config.php file, open up to edit the file in an editor and then upload the file using the same FTP program. Once you are done with the debug options, you may again want to undo the config file changes and resave it.

Using add-on is as simple as clicking a checkbox and then unchecking it.

Note: The addon like config file will enable the debug mode for anyone visiting the site and does not take into account any conditional enabling of debug mode.

How To Enable Debug Mode Only For Selected Users and Without Any Addons?

Debug mode can’t be enabled based on admin permissions because permission set isn’t fetched when the config file is included. So restrict of debug mode for admins will be based on IP address.

Ask Google what’s your IP address or visit WhatsMyIp.org


Now put the following code in the config.php file to enable the debug mode for selected IP.

<?php
//* Do NOT include the opening php tag above. Copy the code shown below.
// Add here your ip.
$debug_ips = array('202.71.5.115');
//For multiple IPs Use this
//$debug_ips = array('202.71.5.115','SOME.OTHER.IP');
if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip_address = $_SERVER['REMOTE_ADDR'];
}
if(in_array($ip_address, $debug_ips))
$config['debug'] = true;
view raw config.php hosted with ❤ by GitHub

Change the IP address to your IP address. If you wish to enable debug mode for multiple IP addresses, use

<?php
//* Do NOT include the opening php tag above. Copy the code shown below.
$debug_ips = array(‘202.71.5.115′,’SOME.OTHER.IP’);
view raw config.php hosted with ❤ by GitHub

Add every IP as comma separated string to enable debug mode for each of the IP address.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)

Filed Under: Tutorials Tagged With: Config.php, Debug Mode, IP, IP Address

About Shabbir Bhimani

xfpoint.com is an independent XenForo resource site with tips, tricks, hacks, and resources for new XenForo webmasters to improve their community. Read More…

Primary Sidebar

About Shabbir Bhimani

xfpoint.com is an independent XenForo resource site with tips, tricks, hacks, and resources for new XenForo webmasters to improve their community. Read More…

© xfpoint 2023. xfpoint.com is an independent XenForo resource site for new xenForo webmasters.

Copyrighted code samples of XenForo will be visible only if you have a valid xenForo license.