Hide PHP Errors From Visitors
Turns off on-screen PHP warnings and errors for everyone except logged-in administrators, so file paths are never shown to the public.
Opens WPIDE on
Code
if ( ! ( is_user_logged_in() && current_user_can( 'manage_options' ) ) ) {
ini_set( 'display_errors', '0' );
}
Notes
Errors are still written to the error log if logging is enabled.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.