Skip to content

pbUsers

Flat list of users with their profiles attached.

[[!pbUsers? &group=`2` &tpl=`chunk:userCard` &limit=`20`]]

Parameters

ParameterDefaultDescription
idsComma-separated ids. Given ids, the output keeps the order you listed them in.
groupUser group id.
roleRole id inside the group.
active1Only active users. Pass 0 to include blocked ones.
whereExtra conditions as JSON.
sortbyField to sort by. Without it the order is whatever the database returns.
sortdirascasc or desc.
limitRows to return; empty means no limit.
offset0Rows 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}

© PageBlocks 2019-present