User

Notice

We have attached an extra organizations attribute to the native User Element (opens new window). You can utilize this attribute on any User Element (opens new window) to get all of the associated Organizations.

# Public Properties

All of the standard User Element (opens new window) public properties are available plus the following:

Property Type Description
organization array (opens new window) , Organization Query Organization Query criteria

# Public Methods

All of the standard User Element (opens new window) public methods are available plus the following:

# getOrganizations( $criteria = [] )

Returns: Organization Query

Argument Accepts Description
$criteria array (opens new window) Organization Query criteria

::: code

{% set organizations = currentUser.getOrganizations({limit: 10}).all() %}
<ul>
{% for organization in organizations %}
    <li>{{ organization.id }} - {{ organization.title }}</li>
{% endfor %}
</ul>
use Craft;

$currentUser = Craft::$app->getUser()->getIdentity();
$organizations = $currentUser->getOrganizations([
    'limit' => 10
]);

foreach ($organizations as $organization) {
    // $organization
}

:::