Appendix: Changing Content Visibility According to User Role

You can conditionally display or hide page content based on which roles have been assigned to the current user. The ISINROLE wrap-around element will only render the enclosed content if the user viewing the page has at least one of the roles specified in the element. The enclosed content can be literal, such as a message to the user, or other elements that you only want to call when the user is logged in.

The element has the following syntax:

<%= ISINROLE(UserRole, UserRole, ... )%>
...content to render...
<%= %>

Enter at least one user role between the parentheses. Multiple roles can be added as a comma-separated list. Notice that this syntax features a tag either side of the content you want to render. Everything within this pair of tags is affected by the tag's behaviour, and will be hidden unless the user has one of the specified roles.

The following example shows an ISINROLE element that will show users with the Customer role a short message:

<%= ISINROLE(Customer)%>
<p>Welcome to our store!</p>
<%= %>

Alternatively, if you want to display content to users who do not have the specified roles, you can use the ISNOTINROLE element. The following example shows an element that will only show the enclosed message to any users who do not have the Administrator or Developer roles:

<%= ISNOTINROLE(Administrator,Developer)%>
<p>Access denied! Insufficient credentials.</p>
<%= %>