How to Allow Displaying PHP Errors to WordPress Administrators?


By default, WordPress suppresses any PHP Errors (and they are written to the Apache2/Nigix log if configured). If wordpress administrators are testing plugins or activating plugins, they might not see errors from the plugins. The following PHP code allows the administrators to see the errors so it becomes easier if plugins have errors. Put the following code at the end of the child theme functions.php template.

1
2
3
4
if ( current_user_can( 'manage_options' ) ) {
    define('WP_DEBUG_DISPLAY', true);
    @ini_set('display_errors', 1);
}
if ( current_user_can( 'manage_options' ) ) {
    define('WP_DEBUG_DISPLAY', true);
    @ini_set('display_errors', 1);
}

So, only the administrators (that can manage options), can see the errors when plugins have PHP error messages. These messages won’t be shown to subscribes, readers or even contributors.

administrators_lg How to Allow Displaying PHP Errors to Wordpress Administrators? php wordpress

Administrators

This is a must-have/handy trick for wordpress programmers!

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
226 words
Last Post: Does Blocking Adsense Categories Help in Earnings?
Next Post: Tips for Improving your Website Layout (how-to)

The Permanent URL is: How to Allow Displaying PHP Errors to WordPress Administrators?

Leave a Reply