Using the remove_menu_page()
function works for removing the default admin menu items by their slug like so:
add_action( 'admin_menu', 'hide_menu' );
function hide_menu() {
remove_menu_page( 'index.php' ); // Dashboard
remove_menu_page( 'tools.php' ); // Tools
}
When a plugin created their own menu in the Dashboard, the URL structure looks like the following:
http://example.com/wp-admin/admin.php?page=plugin-slug
However when trying to remove the custom plugin menu item like so:
remove_menu_page( 'admin.php?page=plugin-slug' );
Nothing changes. Looking at a similar questions here and here, it seems that my function isn't called in time once the custom plugin settings load? Yet, when I try to increase the priority to a higher number, that still doesn't work:
add_action( 'admin_menu', 'hide_menu', 9001, 1 );
Is there a work around? Am I doing this correctly?