Get, find or save users ($users API variable as a function)

This function behaves the same as the $users API variable, though does support an optional shortcut argument for getting a single user or finding multiple users.

Example

// Get a single user (regular and shortcut syntax)
$u = users()->get('karen');
$u = users('karen');

// Find multiple users (regular and shortcut syntax)
$us = users()->find('roles.name=editor');
$us = users('roles.name=editor'); 

Usage

// basic usage
$users = users();

// usage with all arguments
$users = users($selector = '');

Arguments

NameType(s)Description
selector (optional)string, array, int

Optional selector to send to find() or get()

  • Specify user name or ID to get and return that User
  • Specify a selector string to find all users matching selector (PageArray)

Return value

Users PageArray User mixed


Functions methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #514
    In the 514th issue of ProcessWire Weekly we'll check out the latest blog post from Ryan, introduce two new third party modules — Page List Versions Counter and Fieldtype Fieldset Panel — and more. Read on!
    Weekly.pw / 16 March 2024
  • Invoices Site Profile
    The new invoices site profile is a free invoicing application developed in ProcessWire. It enables you to create invoices, record payments to them, email invoices to clients, print invoices, and more. This post covers all the details.
    Blog / 15 March 2024
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull