How to hide WordPress error messages?

how to hide wordpress error message

How to hide WordPress error messages  like  “You do not have sufficient permissions to access this page” and show 404 error page for all non administrator’s request like e.g mydomain.com/wp-admin/plugin.php and all such requests. And they should be redirected to 404 error page.

Here are two solution for your problem, You are requested to take backup of your plugin or theme before implementing this method of your live system.

Copy this code inside you functions.php file or your plugin file depending upon where do you want to redirect your visitor from  showing these error message(s).

Hide WordPress error messages and Redirect visitor on 404 Page

If you want to 404 page of your WordPress theme instead of normal WordPress error message then the code below will do this job very effectively.

function custom_404_die_handler() {
    global $wp;

but if you want to redirect your reader  somewhere, then you could do something like this, but that’s not exactly a “404”, as such. In this code reader will be redirected to the home page of the website/blog.

function custom_404_die_handler() {
    wp_safe_redirect( get_home_url() );

Source : Source : Originally shared by Samuel Wood (Otto) on Wp Answer


The Whole concept was developed by the man you are watching here. I am rakesh Kumar Serial Niche Blogger and SEO Enthusiast. find me onfacebookandon twitter.. Developed popular WordPress theme for Wallpapers and funny Image WordPress theme. Love SEO optimized WordPress theme Designing and Customization.
Related Posts

Leave a Reply

Your email address will not be published.