Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

For a software dev like me who has no idea how to create a cute hand-drawn dashed line, this course just 100% works.

— Ira Zayats, Developer

Users Tag

Anything inside the user:in tag will only be rendered if the user is in the specified group.

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>

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" }}

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" }}

Examples

Only super users

{{ user super:is="true" }}
// these people are powerful
{{ /user }}

Exclude users with gmail email address

{{ users email:doesnt_end_with="@gmail.com" }}
// cool stuff goes here
{{ /users }}

Parameters

group

string

The user group or groups to filter by. You may specify multiple groups by pipe separating them: {{ users group="jocks|geeks" }}.

role

string

The role or roles to filter by. You may specify multiple roles by pipe separating them: {{ users role="author|editor" }}.

sort

string

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

integer

Limit the total results returned.

filter|query_scope

string

Apply a custom query scope

offset

integer

Skip a specified number of results.

as

string

Alias your entries into a new variable loop.

scope

string

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 no_results to check if any results exist.

user data

mixed

Each result has access to all the variables inside that entry (name, email, etc).

Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →