Increase the usability of your WordPress backend by hiding the menus of unused functions.

For common users, some menus in the WordPress background are useless, such as multimedia, tools, etc. The display of useless things will not only cause the complexity of the WordPress background interface to increase, but also bring about some security problems, such as one day a customer installed a certain theme or plugin on a whim, or deleted some of the menus in the back-end, and the website page will be displayed abnormally.

In fact, the only function needed to maintain a website is to publish or update a post, and the other functions need to be changed very rarely after they are set up. Before delivering a WordPress site to normal users, we can hide the menu that is not useful to them, so that normal users can only access the functions they need, the following code can help us to hide some uncommon functions in the backend of WordPress.

// Remove useless menus in the backend
add_action( 'admin_menu', function(){
    remove_menu_page( 'index.php' ); //dashboard
    remove_menu_page( 'upload.php' ); //Multimedia
    remove_menu_page( 'edit.php?post_type=page' ); //Pages
    remove_menu_page( 'edit-comments.php' ); //comments
    remove_menu_page( 'plugins.php' ); //plugins
    remove_menu_page( 'tools.php' ); //tools
    remove_menu_page( 'options-general.php' ); //settings
}).;

The parameter of remove_menu_page is the character string after the last “/” in the URL address of the backend page, besides some built-in addresses of WordPress, we can also hide the menus added by some plugins or themes through this aspect, we just need to add the last slash of the page address as the parameter of remove_menu_page. The characters after the last slash of the page address can be added to the remove_menus function as a parameter of remove_menu_page. For some special pages, you need to add the characters after the last slash of the backend address as a parameter of remove_menu_page. For some special pages, you need to add the characters after the last slash of the page address as the value of remove_menu_page.

Add the above code to the functions.php file of the current theme to hide the menu of unused functions in the backend of WordPress.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *