current user Group assignments

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

current user Group assignments

Post by sfeher » Thu Jan 07, 2016 6:52 pm

Trying to find the appropriate reference for updating the navigation elements.
We want to allow some menu items to display only for specific group members, but I'm unsure how to call the current users' group membership in the code.

Seems like the AbleContext.Current.User should contain the GroupId, but efforts to call this continually fail.

The Admin link in the navigation simply calls the visibility based on the following code in StoreHeader.ascx:

Code: Select all

 AdminLink.Visible = AbleContext.Current.User.IsAdmin;
I'd like to make other menu items comply with similar code

Code: Select all

 GroupLink.Visible = AbleContext.Current.User.GroupId = 14;
Any recommendations?

Thanks!

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: current user Group assignments

Post by jmestep » Thu Jan 07, 2016 11:23 pm

You can use a variation of
if (user.IsInGroup(14))
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: current user Group assignments

Post by sfeher » Fri Jan 08, 2016 4:08 am

Thanks Judy ---
I couldn't see the "IsInGroup" property and wasn't sure how to use it.
I appreciate the response!

Final code for those working on this:

Code: Select all

ForGroupsOnlyLink.Visible = AbleContext.Current.User.IsInGroup(X);
Where "ForGroupsOnly" is the ID and X is your group ID number.....

Works like a champ.

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: current user Group assignments

Post by sfeher » Fri Jan 08, 2016 4:08 am

Thanks Judy ---
I couldn't see the "IsInGroup" property and wasn't sure how to use it.
I appreciate the response!

Final code for those working on this:

Code: Select all

ForGroupsOnlyLink.Visible = AbleContext.Current.User.IsInGroup(X);
Where "ForGroupsOnly" is the ID and X is your group ID number.....

Works like a champ.

Post Reply