Users Tag
The users tag can be used to fetch, filter, and iterate over Users and their data.
Overview#
The Users tag works very much like the Collection Tag. It fetches, filters, sorts, groups, and manipulates lists of your users so you can do whatever you want with them.
A simple example is to loop through all the users and list them by name:
<ul>
{{ users }}
<li>{{ name }}</li>
{{ /users }}
</ul>
<ul>
<s:users>
<li>{{ $name }}</li>
</s:users>
</ul>
Filtering#
You can filter you users by group, role, field, or even custom filter class if you need extra control.
Conditions#
Want to avoid listing users who have the words "hipster" and "coffee" in their bio?
{{ users bio:doesnt_contain="hipster" bio:doesnt_contain="coffee" }}
<s:users
bio:doesnt_contain="hipster"
bio:doesnt_contain="coffee"
>
...
</s:users>
There are a whole pile of conditions available to you, like :is
, :isnt
, :contains
, :starts_with
, and :is_before
. Check out this page dedicated to conditions.
Custom Query Scopes#
Doing something custom or complicated? You can create query scopes to narrow down those results with the query_scope
or filter
parameter:
{{ users query_scope="your_query_scope" }}
<s:users
query_scope="your_query_scope"
>
...
</s:users>
Examples#
Only super users#
{{ users super:is="true" }}
// these people are powerful
{{ /users }}
<s:users
super:is="true"
>
// these people are powerful
</s:users>
Exclude users with gmail email address#
{{ users email:doesnt_end_with="@gmail.com" }}
// cool stuff goes here
{{ /users }}
<s:users
email:doesnt_end_with="@gmail.com"
>
// cool stuff goes here
</s:users>
Parameters
group
The user group or groups to filter by. You may specify multiple groups by pipe separating them: {{ users group="jocks|geeks" }}
.
role
The role or roles to filter by. You may specify multiple roles by pipe separating them: {{ users role="author|editor" }}
.
sort
Sort users by field name (or random
). You may pipe-separate multiple fields for sub-sorting and specify sort direction of each field using a colon. For example, sort="title"
or sort="date:asc|title:desc"
to sort by date then by title.
limit
Limit the total results returned.
filter|query_scope
Apply a custom query scope
offset
Skip a specified number of results.
as
Alias your entries into a new variable loop.
scope
Scope your entries with a variable prefix.
Variables
Variable | Type | Description |
---|---|---|
first |
boolean |
Is this the first item in the loop? |
last |
boolean |
Is this the last item in the loop? |
count |
integer |
The number/index of current iteration in the loop, starting from 1 |
index |
integer |
The number/index of current iteration in the loop, starting from 0 |
no_results |
boolean |
Returns true if there are no results. |
total_results |
integer |
The total number of results in the loop when there are results. You should use |
user data |
mixed |
Each result has access to all the variables inside that entry ( |
Docs Feedback
Submit improvements, related content, or suggestions through Github.
Betterify this page