• Resolved GusGF

    (@gusgf)


    One of the annoyances of working with WordPress I’ve had for ages is trying to use the error_reporting() function to do something like temporarily turn off deprecation warnings; WordPress ignores these settings entirely.
    Turns out the cause of this is the wp_debug_mode() function, which gets called by wp-settings.php and sets error_reporting(E_ALL). As a result, putting your own call to the error_reporting() function in wp-config.php won’t have any effect; you need to place your call after wp_debug_mode() runs. One smart solution is to create a very simple mu-plugin for this purpose.

    Managed to find the above while trying to find an answer to my question i.e. how to set error reporting levels for php in WP. So in wp-settings.php I’ve got a call to my function: setErrorLevel(); after the line containing wp_debug_mode() and in my mu-plugins folder I’ve got a file called myConfigSettings.php which has the following function:

    <?php 
        function setErrorLevel(){
        }
    ?>

    But I’m getting error
    PHP Fatal error: Uncaught Error: Call to undefined function setErrorLevel() in C:\Users\Fergus\Local Sites\university01\app\public\wp-settings.php:82

    Any suggestions please how to resolve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Dion

    (@diondesigns)

    The only thing you need to do is to set the error level in your plugin code. You don’t even need a function, just set error_reporting().

    Plugins are loaded after the call to wp_debug_mode() (which is why you received the error you did; the mu plugin wasn’t loaded yet), so there is no need to edit wp-settings.php.

    Thread Starter GusGF

    (@gusgf)

    Thank you Dion.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set the error reporting level in WP’ is closed to new replies.