UserAspect

final readonly class \TYPO3\CMS\Core\Context\UserAspect

Implements
AspectInterface

The aspect contains information about a user.

Can be used for frontend and backend users.

Allowed properties:

  • id
  • username
  • isLoggedIn
  • isAdmin
  • groupIds (Array of Ids)
  • groupNames

Table of Contents

Interfaces

AspectInterface
Interface AspectInterface Think of an aspect like a property bag

Methods

__construct()  : mixed
get()  : mixed
Fetch common information about the user
getGroupIds()  : array
Return the groups the user is a member of
getGroupNames()  : array
Get the name of all groups, used in Fluid's IfHasRole ViewHelper
isAdmin()  : bool
Check if admin is set
isLoggedIn()  : bool
A user is logged in if the user has a UID, but does not care about groups.
isUserOrGroupSet()  : bool
Checking if a user is logged in or a group constellation different from "0,-1"

Methods

__construct()

public __construct([AbstractUserAuthentication|null $user = null ][, array|null $alternativeGroups = null ]) : mixed

Parameters

$user : AbstractUserAuthentication|null = null
$alternativeGroups : array|null = null

Alternative list of groups, usually useful for frontend logins with "magic" groups like "-1" and "-2"

getGroupIds()

Return the groups the user is a member of

public getGroupIds() : array

For Frontend Users there are two special groups: "-1" = hide at login "-2" = show at any login

Return values

array

getGroupNames()

Get the name of all groups, used in Fluid's IfHasRole ViewHelper

public getGroupNames() : array

Return values

array

isAdmin()

Check if admin is set

public isAdmin() : bool

Return values

bool

isLoggedIn()

A user is logged in if the user has a UID, but does not care about groups.

public isLoggedIn() : bool

For frontend purposes, it is possible to e.g. simulate groups, but this would still be defined as "not logged in".

For backend, only the check on the user ID is used.

Return values

bool

isUserOrGroupSet()

Checking if a user is logged in or a group constellation different from "0,-1"

public isUserOrGroupSet() : bool

Return values

bool —

TRUE if either a login user is found OR if the group list is set to something else than '0,-1' (could be done even without a user being logged in!)

On this page