The $user API variable is a type of page representing the current user, and the User class is Page type used for all users.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the User
class also inherits all the methods and properties of: Page, WireData and Wire.
Common
Name | Return | Summary | |
---|---|---|---|
$user->addRole() $user->addRole($role) $user->addRole($role) | bool | Add Role to this user | |
$user->admin_theme | string | Admin theme class name | |
$user->changed() $user->changed(string $what) $user->changed(string $what, mixed $old = null, mixed $new = null) | (nothing) | Hook called when field has changed | |
$user->email | string | Get or set email address for this user. | |
$user->getPermissions() $user->getPermissions() $user->getPermissions(Page $page = null) | PageArray | Get this user’s permissions, optionally within the context of a Page. | |
$user->hasPermission() $user->hasPermission($name) $user->hasPermission($name, $context = null) | bool array | Does the user have the given permission? | |
$user->hasRole() $user->hasRole($role) $user->hasRole($role) | bool | Does this user have the given Role? | |
$user->hasTfa() $user->hasTfa() $user->hasTfa(bool $getInstance = false) | bool string Tfa | Does user have two-factor authentication (Tfa) enabled? (and what type?) | |
$user->isGuest() $user->isGuest() $user->isGuest() | bool | Is this the non-logged in guest user? | |
$user->isLoggedin() $user->isLoggedin() $user->isLoggedin() | bool | Is the current user logged in? | |
$user->isSuperuser() $user->isSuperuser() $user->isSuperuser() | bool | Does this user have the superuser role? | |
$user->language | Language | User language, applicable only if LanguageSupport installed. | |
$user->pass | string Password | Set the user’s password. | |
$user->removeRole() $user->removeRole($role) $user->removeRole($role) | bool | Remove Role from this user | |
$user->roles | PageArray | Get the roles this user has. |
For hooks
These methods are only useful for hooking and should not be called directly.
Name | Return | Summary | |
---|---|---|---|
$user->hasPagePermission() $user->hasPagePermission($name) $user->hasPagePermission($name, Page $page = null) | bool | Does this user have named permission for the given Page? | |
$user->hasTemplatePermission() $user->hasTemplatePermission($name, $template) $user->hasTemplatePermission($name, $template) | bool | Does this user have the given permission on the given template? |
Additional methods and properties
In addition to the methods and properties above, User also inherits the methods and properties of these classes:
API reference based on ProcessWire core version 3.0.172