Showing content based on user group

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

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

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%>

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

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

1 Like

Amazing! thank you works perfectly