Showing content based on user group

silverstripe-3
Tags: #<Tag:0x00007f10c802a758>

#1

Using SS3, trying to get a way of only showing information on a page dependant on what group the current member is logged in as?

Currently created a group called ‘corporate members’ and only want to show content of the page to that specific user group.

Thanks in advance.

Regads

Anish


#2

Hi Anish, if you’re happy to display a generic “You don’t have permission to access that” message to everyone else, you can achieve that with the ‘Who can view this page?’ field on the Settings tab for your page.

59%20am


#3

It will be more complex than that, I’ll basically have a few files on that page itself, some available to all members and some to a particular user group.

So wanted an if statement like

<% if CurrentMember ==“Corporate member”%>
Downloadable files for that user group
<% else%>
Downloadable files for non logged in users
<% end_if%>


#4

Okay, then you can try <% if $CurrentMember.inGroup('corporate-member') %>

https://api.silverstripe.org/3/Member.html#method_inGroup


#5

Amazing! thank you works perfectly