Title: Problem customising admin menu
Last modified: April 13, 2020

---

# Problem customising admin menu

 *  [myszek](https://wordpress.org/support/users/myszek/)
 * (@myszek)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/problem-customising-admin-menu/)
 * Hi all, I have started with customising the admin menu for different user roles
   this weekend and can say that I have surprised myself. With all information I
   have found on this and other forums, I have achieved what I wanted except for
   one issue I ran into. It feels as if I have searched the entire internet, but
   I can’t find the answer.
 * I have a WP + WC (+WC admin) setup. For a certain user role I want a custom admin
   menu, showing only the Dashboard, ‘My orders’ and ‘My stock’. I have eliminated
   access to unwanted items using the AAM plugin.
 * As I do need to use some functions from WC and WC admin but under different names,
   I have used the following snippets to achieve what I have now:
 * To hide menu items:
 *     ```
       add_action( 'admin_init', 'remove_menu_pages_for_all_except_admin' );
       function remove_menu_pages_for_all_except_admin() {
   
       global $user_ID;
   
       if ( !current_user_can('administrator') ) {
       remove_menu_page('woocommerce');
       remove_menu_page('wc-admin&path=/analytics/revenue'); 
       }
       }
       ```
   
 * To add custom menu items:
 *     ```
       add_menu_page('My orders','My orders','enduser', 'edit.php?post_type=shop_order', '','dashicons-archive', 8);
       add_menu_page('My stock','My stock','enduser', 'admin.php?page=wc-admin&path=/analytics/stock', '','dashicons-pressthis', 9); 
       ```
   
 * Both snippets work and do their job, but I have the issue that the stock report(
   wc-admin&path=/analytics/stock) is not accessible anymore. The page loads fine,
   but doesn’t output stock results.
 * I can’t figure out what I have to do to make this work. Basically all I need 
   is to have the menu item “Analytics” hidden from the menu, just as I did with“
   Woocommerce”. Only Analytics is not called Analytics.
 * Any insight into how to solve this is much appreciated!!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [myszek](https://wordpress.org/support/users/myszek/)
 * (@myszek)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/problem-customising-admin-menu/#post-12665916)
 * Ah, one remark: I am aware that the code I use only allows the administrator 
   to see the removed menu items, and not so much hides them from a specific user
   role. That is a next step I’ll take, I just want to figure out the item hiding
   first.
 *  Thread Starter [myszek](https://wordpress.org/support/users/myszek/)
 * (@myszek)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/problem-customising-admin-menu/#post-12680156)
 * Is there really no one that could point me in the right direction?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem customising admin menu’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [myszek](https://wordpress.org/support/users/myszek/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/problem-customising-admin-menu/#post-12680156)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
