Umbraco 8 - restrict items on the product page to certain menber groups
Taking the Umbraco 8 starter site as an example, within the products page, is it possible to restrict different products to different member groups?
Eg, show all 8 products, but if the user is not a member of a premium group they can only access certain ones?
If I click on a product in back office, under actions I can see I can amend the public access there, but that then prevented the entire page from being viewed.
You could use the IsUserInRole method to detect whether the currently logged in Member is in a particular member group, to show or hide particular content:
or you could add a 'Member Group Picker' to the Product Type to pick which Member Groups should have access to the particular product, and then get a list of the Current Users Member groups using:
@{
var currentUsersRoles = Roles.GetRolesForUser();
}
and then use this to filter the products so you only show ones with MemberGroups that match the current users...
Umbraco 8 - restrict items on the product page to certain menber groups
Taking the Umbraco 8 starter site as an example, within the products page, is it possible to restrict different products to different member groups?
Eg, show all 8 products, but if the user is not a member of a premium group they can only access certain ones?
If I click on a product in back office, under actions I can see I can amend the public access there, but that then prevented the entire page from being viewed.
thanks
Hi Damion
You could use the IsUserInRole method to detect whether the currently logged in Member is in a particular member group, to show or hide particular content:
or you could add a 'Member Group Picker' to the Product Type to pick which Member Groups should have access to the particular product, and then get a list of the Current Users Member groups using:
and then use this to filter the products so you only show ones with MemberGroups that match the current users...
regards
marc
Hi
thanks for the reply. I like the look of IsUserInRoll, I'll try it shortly, this would go in as a macro then?
thanks
Hi Damion
Yes in a Template/View, Partial View or Macro Partial.
Should be the same.
regards
Marc
is working on a reply...