Role based pages
Often you'll want a site to have pages that vary based on the role of the visitor. This is commonly the case on the homepage, where somebody logged out sees something different to someone logged in. SocialStack has a built in mechanism to make content vary by role - it can be applied to any type of content, but given that it is often applied to pages, let's explore how that is done.
Setting up the roles
Firstly, a quick recap of how Permissions work in SocialStack: a visitor to the site is exactly one role, and a role defines a list of capabilities which define what visitors of that role can do.
So, to make pages vary by role, we'll need to change the page_load and page_list capabilities on the target roles. They default to "always granted" meaning everyone can see every page. If we make it a conditional grant then the visibility of a particular page to someone will be based on some specified rule - in this case, we'll use HasRolePermit: