How to determine customer role

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 年 前
I am working on a project trying to implement a way to display a specific category when someone is logged in as a custom role (Wholesaler). The problem is determining whether a person belongs to a specific role. The end goal is to hide a wholesale category for regular registered users, and then for wholesalers hide all categories except the wholesale category.

Tried using this code to determine the user role:


@(HttpContext.Current.User.IsInRole("Wholesaler"))


But it results in an error:

Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException (0x80131904): Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed

Can anyone help out?
12 年 前
geige003 wrote:
I am working on a project trying to implement a way to display a specific category when someone is logged in as a custom role (Wholesaler). The problem is determining whether a person belongs to a specific role. The end goal is to hide a wholesale category for regular registered users, and then for wholesalers hide all categories except the wholesale category.

Tried using this code to determine the user role:


@(HttpContext.Current.User.IsInRole("Wholesaler"))


But it results in an error:

Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException (0x80131904): Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed

Can anyone help out?

What you need is available in V1.9 as ACL on categories. You can use it or have a look to the code to get an idea of how it  was implemented there.
This feature has not not been developed in v2.x but for more information or for voting you can have look to the work items for ACL on Categories and ACL on Products.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.