User-roles Tag
The user_roles
tag is used to return any roles you have added to collate the users on your site.
Overview#
The User Roles tag fetches lists of the user roles on your site so you can do whatever you want with them.
A simple example is to loop through all the roles and list them by handle:
<ul>
{{ user_roles }}
<li>{{ handle }}</li>
{{ /user_roles }}
</ul>
<ul>
<s:user_roles>
<li>{{ $handle }}</li>
</s:user_roles>
</ul>
{{-- Aliasing the roles. --}}
<s:user_roles
as="roles"
>
...
@foreach ($roles as $role)
...
@endforeach
...
</s:user_roles>
Filtering#
If you only want a specific role or roles, you can pass their handle(s) using the handle
parameter.
{{ user_roles handle="role_1|role_2" }}
// cool stuff goes here
{{ /user_roles }}
<s:user_roles
handle="role_1|role_2"
>
// cool stuff goes here
</s:user_roles>
Parameters
handle
string
The handle(s) of the roles you want to return. You may specify multiple roles by pipe separating them: {{ user_roles handle="jocks|geeks" }}
.
Variables
Variable | Type | Description |
---|---|---|
handle |
string |
The role's unique identifier. |
title |
string |
The role's display title. |
Docs Feedback
Submit improvements, related content, or suggestions through Github.
Betterify this page