posted by  on  

In nopcommerce adding a new menu item in Admin Panel, Steps to hide admin menu items based on roles.

In this blog, i am adding a new menu in admin panel and hide some menu based on customer role.

Right now menu in admin panel like this

Admin menu

Step 1

Nop.Admin area find sitemap.config

In your sitemap add following code

<siteMapNode SystemName="ManageMymenu" nopResource="Admin.Mymenu" PermissionNames="ManageMymenu" IconClass="fa-book" >
      <siteMapNode SystemName="ManageMymenuSubmenu1" nopResource="Admin.Mymenu.Submenu1" PermissionNames="ManageMymenuSubmenu1" controller="MyController" action="Submenu1" IconClass="fa-dot-circle-o"/>
      <siteMapNode SystemName="ManageMymenuSubmenu2" nopResource="Admin.Mymenu.Submenu2" PermissionNames="ManageMymenuSubmenu2" controller="MyController" action="Submenu2" IconClass="fa-dot-circle-o"/>

Note : Provide different permission name to every sitemapnode, because different ACL for menu. The only reason is to show you how it can work for complete menu item or its sub-menu items in case you would like to hide only the sub-menu items for any user based on his/her role.

Step 2

Nop.Services area find StandardPermissionProvider.cs and add following code

public static readonly PermissionRecord ManageMymenu = new PermissionRecord { Name = "Admin area. Manage Mymenu", SystemName = "ManageMymenu", Category = "MyMenu" };
public static readonly PermissionRecord ManageMymenuSubmenu1 = new PermissionRecord { Name = "Admin area. Manage MymenuSubmenu1", SystemName = "ManageMymenuSubmenu1", Category = "MyMenu" };
public static readonly PermissionRecord ManageMymenuSubmenu2 = new PermissionRecord { Name = "Admin area. Manage MymenuSubmenu2", SystemName = "ManageMymenuSubmenu2", Category = "MyMenu" };

Add this value in GetPermissions() method and GetDefaultPermissions() method in StandardPermissionProvider.cs

public virtual IEnumerable<PermissionRecord> GetPermissions()
    return new[] 
        // all permissions are above already
public virtual IEnumerable<DefaultPermissionRecord> GetDefaultPermissions()
    return new[] 
        new DefaultPermissionRecord 
            CustomerRoleSystemName = SystemCustomerRoleNames.Administrators,
            PermissionRecords = new[] 
                // all permissions are above already

Step 3

Now go to your nopCommerce database and find table PermissionRecord

Add this new record

  • Name: Admin area. Manage Mymenu
  • SystemName: ManageMymenu
  • Category: Mymenu

In the same manner, add new record for each sub menu like this

Permission Table

Step 4

Now build and run project and login as admin.

You will notice that you will not see "MyMenu”. The reason is because you have added a new property and by default you are not allowed to see it. Go to Access Control List under Configuration menu and you should see a new properties that you just added like this

ACL List

Step 5

Check these properties for your Administrator role and once you save you will see the admin.mymenu.


Go to Language under Configuration menu. Click string resource link for english language and add resourcename like “admin.mymenu” and resourcevalue like My Menu.

My Menu

Same way you can give hide menus for other users based on roles from the access control list and uncheck whatever you want.

Lateshtclick Technology Blog
Tags NopCommerce MVC
posted by Latesht Click Latesht Click


Phạm Văn Thủy


Good ! Thank you ! :D

Leave a Reply

Feel free to contribute!