Turn on PHP Error Logging for Admins in WordPress

In my last post I reminded you all how to turn on error monitoring and I decided I wanted to add a quick foot note to that in a new post.

I do quite a bit of custom code for people who use wordpress and recently I did a very simple hack so that WordPress Admins would see any page errors but regular users would not. The code is quite simple and is as follows


if(is_admin())
{
error_reporting(E_ALL);
ini_set('display_errors', 'on');
}

I put this code in header.php and it will display on the page any PHP errors as they happen but ONLY for administrators. Regular users will not see the php errors. Its a nice way to do php debugging without interfering with readers.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s