pbUsers
Flat list of users with their profiles attached.
[[!pbUsers? &group=`2` &tpl=`chunk:userCard` &limit=`20`]]Parameters
| Parameter | Default | Description |
|---|---|---|
ids | Comma-separated ids. Given ids, the output keeps the order you listed them in. | |
group | User group id. | |
role | Role id inside the group. | |
active | 1 | Only active users. Pass 0 to include blocked ones. |
where | Extra conditions as JSON. | |
sortby | Field to sort by. Without it the order is whatever the database returns. | |
sortdir | asc | asc or desc. |
limit | Rows to return; empty means no limit. | |
offset | 0 | Rows to skip. |
Plus the shared output parameters from Intro.
The profile is already loaded
Each row comes with its profile eager-loaded, so the template does not fire a query per user:
php
<div class="user">
<img src="{$item->profile->photo}" alt="">
<span>{$item->profile->fullname}</span>
</div>Read profile fields through the profile
In MODX the user row holds little more than the username — email, fullname and the rest live in the profile. {$item->email} is empty; {$item->profile->email} is not.
Examples
Members of a group
[[!pbUsers? &group=`2` &tpl=`chunk:userCard`]]Specific users, in the given order
[[!pbUsers? &ids=`12,7,3` &tpl=`chunk:userCard`]]Including blocked users
[[!pbUsers? &active=`0` &tpl=`chunk:userRow` &sortby=`username`]]From Fenom
php
{foreach users(['group' => 2, 'limit' => 10]) as $item}
{$item->profile->fullname}
{/foreach}