WordPress.org

Ready to get started?Download WordPress

Forums

WP_DEBUG on only for admin user? (2 posts)

  1. KatieBen
    Member
    Posted 2 years ago #

    Hi there,

    How would I set WP_DEBUG to true, only for the admin user? I tried checking for the user ID 1, via:

    if(function_exists("wp_get_current_user") && wp_get_current_user()->ID == 1)
    define('WP_DEBUG', true);
    else
    define('WP_DEBUG', false);

    I tried putting this in both the config file and the header file of my theme, though neither worked. Has anyone done this?

  2. Jackson
    Member
    Posted 2 years ago #

    I think that wp-config.php is too early to check for the user, and your theme's functions.php file is too late to define WP_DEBUG - of course I could be wrong...

    Instead you could setup an error log, and silence the notices.

    `/**
    * This will log all errors notices and warnings to a file called debug.log in
    * wp-content (if Apache does not have write permission, you may need to create
    * the file first and set the appropriate permissions (i.e. use 666) )
    */
    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);
    @ini_set('display_errors',0);`

    http://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Log

Topic Closed

This topic has been closed to new replies.

About this Topic