Changing WordPress backend layout (removing certain tabs)

Currently, if any user (besides an admin) logs into WordPress backend, it shows them the following tabs:

enter image description here

What I'm trying to do is to:

  1. Remove the dashboard tab
  2. Remove the profile tab
  3. Open up the WooCommerce orders tab by default (so it shows immediately when the user logs in).

Essentially, something like this:

enter image description here

To do this, I've tried the following:

function remove_profile_menu() {
  if ( !is_admin() ) {
    remove_submenu_page(‘users.php’, ‘profile.php’);
    remove_menu_page(‘profile.php’);
  }
}

add_action('admin_menu', 'remove_profile_menu');

function remove_dashboard_menu() {
  if ( !is_admin() ) {
    remove_submenu_page(dashbourd.php’);
    remove_menu_page(dashboard.php’);
  }
}

add_action('admin_menu', 'remove_dashboard_menu');

But the above does nothing when ran?

Solutions

Your given code have several problems.

  1. Syntax errors.
  2. Wrong function - is_admin is for checking whether the current page belongs to wp-admin. I guess you wanted to check "is current user admin" - for that purpose you should use current_user_can function.

Here is working code for your case:

function remove_dashboard_menu() {
  if (!current_user_can('administrator') ) {
    remove_menu_page('index.php');
    remove_menu_page('users.php');
  }
}

add_action('admin_menu', 'remove_dashboard_menu');
Tags: PHP / Html / Wordpress

Similar questions

How can I detect a chosen Isotope layout option from within Javascript to generate appropriate layout?
I am trying to make a custom gallery post where a user may select Isotope layout modes (masonry, packery etc.). I don't want to create a custom template for each layout mode and then get it depending on whether a post includes a certain layout option. It seems that this solution will require a lot of duplicate code. Is it possible to access the cho...
how to force tag page layout to use same as search layout?
I have remarked that when clicking on a tag I have a list of posts displayed differently that when I use search box. How to force tag page layout to use same as search layout for any template ?
Regex to redirect any url ending in ?layout=mobi or ?layout=full to homepage
Changed my site to wordpress. Used to have mobile and full site options where ?layout=mobi or ?layout=full would call on those files. Now getting lots of 404s in WMT for example.com/page1.html?layout=mobi I'm looking for regex to just redirect all 404s that end in ?layout=full or ?layout=mobi to the homepage of the site so that these 404s don't clo...
Issue removing Media Editor Tabs -- Duplicate Items
I'm following the advice found in several places to remove tabs by using the following filter. However, the same number of tabs appear, the last one is simply displayed x number of times. I'm running Multisite, 4.0 The filter: The screenshot:
What is the code flow at the backend of wordpress-woocommerce?For example how the order listing is loaded at backend?
I am not able to find which template, action and database query I can look for the back-end of woocommerce(for example order list page).
Removing large gap between rows in flexbox layout
I have a sidebar that is longer than the content (post previews with thumbnails). I am using flexbox to build the layout and when the sidebar is longer than the previews, there is a huge gap in between. I want each row to not have a gap in between as it would if the sidebar was nice and short. I have thrown together a codepen.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.