So as you loop through each navigation item, call Umbraco.MemberHasAccess( on each item, if and this will return true if the current member is in a member group that has access to the page.
There is an overhead to performing this kind of lookup to the db, and you'd have to make sure the Member 'Member Group' doesn't have access to the pages in the navigation, as membership of that group would then grant access to anything anyway...
What I tend to do in this scenario, is add a 'MemberGroupPicker' property to the pages within the Member area, and pick which groups have access to the particular subpages, and then compare these picked values with the current logged in User's assigned roles which you can find via:
Show only navigation for allowed member group
I have two types of member groups. One which gives access to a member area. And another which gives acccess to further pages within the member area.
Right now if you are not in the member group, you cannot access them. But you can still see them.
Is there a way for me to show only the pages in navigation, of which you are a member of.
The two groups are "Member", and "Board Member", to be a board member, you also has to be a member.
So i need some way of checking if you are both.
Have not been able to find a way so far.
Using umbraco 7.12.
Hi André
There is a 'MemberHasAccess' helper you could use when writing out your navigation:
https://our.umbraco.com/documentation/reference/querying/umbracohelper/#member-helpers
So as you loop through each navigation item, call Umbraco.MemberHasAccess( on each item, if and this will return true if the current member is in a member group that has access to the page.
There is an overhead to performing this kind of lookup to the db, and you'd have to make sure the Member 'Member Group' doesn't have access to the pages in the navigation, as membership of that group would then grant access to anything anyway...
What I tend to do in this scenario, is add a 'MemberGroupPicker' property to the pages within the Member area, and pick which groups have access to the particular subpages, and then compare these picked values with the current logged in User's assigned roles which you can find via:
string[] currentUserRoles = System.Web.Security.Roles.GetRolesForUser();
regards
Marc
So far i made this, it is a bit ... hacky ?
But works fine so far, although i do not know what kind of performance impact it will have, since it is called in the master controller..
Would this be better, than "has access" ?
Hi André
I think you could shorten that to:
var isBoardMember = System.Web.Security.Roles.IsUserInRole("Board Members");
https://docs.microsoft.com/en-us/dotnet/api/system.web.security.roles?view=netframework-4.7.2
Which will check if the current logged in user is in the Board Members role...
regards
Marc
is working on a reply...