User

Type
Class
Namespace
craft\elements
Inherits
craft\elements\User » craft\base\Element » craft\base\Component » craft\base\Model » yii\base\Model (opens new window) » yii\base\Component (opens new window) » yii\base\BaseObject (opens new window)
Implements
ArrayAccess (opens new window), IteratorAggregate (opens new window), craft\base\ComponentInterface, craft\base\ElementInterface, craft\base\ModelInterface, yii\base\Arrayable (opens new window), yii\base\Configurable (opens new window), yii\base\StaticInstanceInterface (opens new window), yii\web\IdentityInterface (opens new window)
Uses traits
craft\base\ClonefixTrait, craft\base\ElementTrait, craft\base\NameTrait, yii\base\ArrayableTrait (opens new window), yii\base\StaticInstanceTrait (opens new window)
Since
3.0.0

User represents a user element.

View source (opens new window)

# Public Properties

Property Description
active boolean (opens new window) – Active
activeValidators (opens new window) yii\validators\Validator (opens new window) – The validators applicable to the current scenario (opens new window).
additionalButtons string (opens new window)
addresses craft\elements\Address[], null (opens new window) – the user’s addresses
admin boolean (opens new window) – Admin
ancestors craft\elements\db\ElementQueryInterface – The element’s ancestors
archived boolean (opens new window) – Whether the element is archived
attributes (opens new window) array (opens new window) – Attribute values (name => value).
authError string (opens new window), null (opens new window) – Auth error
authKey string (opens new window), null (opens new window) – A key that is used to check the validity of a given identity ID.
awaitingFieldValues boolean (opens new window) – Whether the element is still awaiting its custom field values
behaviors (opens new window) yii\base\Behavior (opens new window) – List of behaviors attached to this component.
cacheTags string (opens new window)[]
canonical craft\base\ElementInterface, null (opens new window) – The canonical element, if one exists for the current site
canonicalId integer (opens new window), null (opens new window) – The element’s canonical ID
canonicalUid string (opens new window) – The element’s canonical UID
children craft\elements\db\ElementQueryInterface – The element’s children
contentId integer (opens new window), null (opens new window) – The element’s content row ID
contentTable string (opens new window) – The name of the table this element’s content is stored in
cooldownEndTime DateTime (opens new window), null (opens new window) – the time when the user will be over their cooldown period
cpEditUrl string (opens new window), null (opens new window) – The element’s edit URL in the control panel
cpRevisionsUrl string (opens new window), null (opens new window)
currentPassword string (opens new window), null (opens new window) – Current password
currentRevision self, null (opens new window)
dateCreated DateTime (opens new window), null (opens new window) – The date that the element was created
dateDeleted DateTime (opens new window), null (opens new window) – The date that the element was trashed
dateLastMerged DateTime (opens new window), null (opens new window) – The date that the canonical element was last merged into this one
dateUpdated DateTime (opens new window), null (opens new window) – The date that the element was last updated
descendants craft\elements\db\ElementQueryInterface – The element’s descendants
dirtyAttributes string (opens new window)[]
dirtyFields string (opens new window)[]
draftId integer (opens new window), null (opens new window) – The ID of the draft’s row in the drafts table
duplicateOf craft\base\ElementInterface, null (opens new window) – The element that this element is being duplicated by.
editorHtml string (opens new window) – The HTML for the element’s editor HUD
email string (opens new window), null (opens new window) – Email
enabled boolean (opens new window) – Whether the element is enabled
enabledForSite boolean (opens new window) – Whether the element is enabled for this site
errors (opens new window) array (opens new window) – Errors for all attributes or the specified attribute.
fieldColumnPrefix string (opens new window) – The field column prefix this element’s content uses
fieldContext string (opens new window) – The field context this element’s content uses
fieldLayout craft\models\FieldLayout, null (opens new window) – The field layout used by this element
fieldLayoutId integer (opens new window), null (opens new window) – The element’s field layout ID
fieldParamNamespace array (opens new window) – The namespace used by custom field params on the request
fieldValues array (opens new window) – The element’s normalized custom field values, indexed by their handles
firstErrors (opens new window) array (opens new window) – The first errors.
firstName string (opens new window), null (opens new window) – First name
firstSave boolean (opens new window) – Whether the element is being saved for the first time in a normal state (not as a draft or revision).
friendlyName string (opens new window), null (opens new window) – the user’s first name or username
fullName string (opens new window), null (opens new window) – Full name
gqlTypeName string (opens new window)
groups craft\models\UserGroup[] – the user’s groups
hardDelete boolean (opens new window) – Whether the element is being hard-deleted.
hasCheckeredThumb boolean (opens new window)
hasDashboard boolean (opens new window) – Whether the user has a dashboard
hasDescendants boolean (opens new window) – Whether the element has descendants
hasRoundedThumb boolean (opens new window)
htmlAttributes array (opens new window) – Any attributes that should be included in the element’s DOM representation in the control panel
id integer (opens new window), null (opens new window) – The element’s ID
inheritorOnDelete self, null (opens new window) – The user who should take over the user’s content if the user is deleted.
invalidLoginCount integer (opens new window), null (opens new window) – Invalid login count
isCanonical boolean (opens new window) – Whether this is the canonical element
isCredentialed boolean (opens new window) – whether the user account can be logged into
isCurrent boolean (opens new window) – whether this is the current logged-in user
isDerivative boolean (opens new window) – Whether this is a derivative element, such as a draft or revision
isDraft boolean (opens new window)
isFresh boolean (opens new window)
isHomepage boolean (opens new window)
isNewForSite boolean (opens new window) – Whether the element is being saved to the current site for the first time.
isProvisionalDraft boolean (opens new window) – Whether this is a provisional draft.
isRevision boolean (opens new window)
isTitleTranslatable boolean (opens new window)
isUnpublishedDraft boolean (opens new window)
iterator (opens new window) ArrayIterator (opens new window) – An iterator for traversing the items in the list.
language string (opens new window)
lastInvalidLoginDate DateTime (opens new window), null (opens new window) – Last invalid login date
lastLoginAttemptIp string (opens new window), null (opens new window) – Last login attempt IP address.
lastLoginDate DateTime (opens new window), null (opens new window) – Last login date
lastName string (opens new window), null (opens new window) – Last name
lastPasswordChangeDate DateTime (opens new window), null (opens new window) – Last password change date
level integer (opens new window), null (opens new window) – The element’s level within its structure
lft integer (opens new window), null (opens new window) – The element’s left position within its structure
link \Twig\Markup, null (opens new window) – An anchor pre-filled with this element’s URL and title
localized craft\elements\db\ElementQueryInterface, \Illuminate\Support\Collection
locked boolean (opens new window) – Locked
lockoutDate DateTime (opens new window), null (opens new window) – Lockout date
mergingCanonicalChanges boolean (opens new window) – Whether recent changes to the canonical element are being merged into this element.
metadata array (opens new window) – The data, with keys representing the labels.
modifiedAttributes string (opens new window)[]
modifiedFields string (opens new window)[]
name string (opens new window) – the user’s full name or username
newPassword string (opens new window), null (opens new window) – New password
newSiteIds integer (opens new window)[] – The site IDs that the element was just propagated to for the first time.
next craft\base\ElementInterface, null (opens new window) – The next element relative to this one, from a given set of criteria
nextSibling craft\base\ElementInterface, null (opens new window) – The element’s next sibling
outdatedAttributes string (opens new window)[]
outdatedFields string (opens new window)[]
parent craft\base\ElementInterface, null (opens new window) – The element’s parent
parentId integer (opens new window), null (opens new window) – The element’s parent’s ID
parentUri string (opens new window), null (opens new window)
password string (opens new window), null (opens new window) – Password
passwordResetRequired boolean (opens new window) – Password reset required
pending boolean (opens new window) – Pending
photo craft\elements\Asset, null (opens new window) – the user’s photo
photoId integer (opens new window), null (opens new window) – Photo asset ID
postEditUrl string (opens new window), null (opens new window)
preferences array (opens new window) – the user’s preferences
preferredLanguage string (opens new window), null (opens new window) – the user’s preferred language
preferredLocale string (opens new window), null (opens new window) – the user’s preferred formatting locale
prev craft\base\ElementInterface, null (opens new window) – The previous element relative to this one, from a given set of criteria
prevSibling craft\base\ElementInterface, null (opens new window) – The element’s previous sibling
previewTargets array (opens new window)
previewing boolean (opens new window) – Whether the element is currently being previewed.
propagateAll boolean (opens new window) – Whether all element attributes should be propagated across all its supported sites, even if that means overwriting existing site-specific values.
propagating boolean (opens new window) – Whether the element is being saved in the context of propagating another site's version of the element.
ref string (opens new window), null (opens new window) – The reference string to this element
remainingCooldownTime DateInterval (opens new window), null (opens new window) – the remaining cooldown time for this user, if they've entered their password incorrectly too many times
resaving boolean (opens new window) – Whether the element is being resaved by a ResaveElement job or a resave console command.
revisionId integer (opens new window), null (opens new window) – The ID of the revision’s row in the revisions table
rgt integer (opens new window), null (opens new window) – The element’s right position within its structure
root integer (opens new window), null (opens new window) – The element’s structure’s root ID
route mixed – The route that should be used when the element’s URI is requested
scenario (opens new window) string (opens new window) – The scenario that this model is in.
searchScore integer (opens new window), null (opens new window) – The element’s search score, if the craft\elements\db\ElementQuery::search() parameter was used when querying for the element
serializedFieldValues array (opens new window) – Array of the element’s serialized custom field values, indexed by their handles
siblings craft\elements\db\ElementQueryInterface – All of the element’s siblings
site craft\models\Site – Site the element is associated with
siteId integer (opens new window), null (opens new window) – The site ID the element is associated with
siteSettingsId integer (opens new window), null (opens new window) – The ID of the element’s record in the elements_sites table
slug string (opens new window), null (opens new window) – The element’s slug
sourceId integer (opens new window), null (opens new window)
sourceUid string (opens new window)
status string (opens new window), null (opens new window) – The element’s status
structureId integer (opens new window), null (opens new window) – The element’s structure ID
supportedSites integer (opens new window)[], array (opens new window) – The sites this element is associated with
suspended boolean (opens new window) – Suspended
tempId string (opens new window), null (opens new window) – The element’s temporary ID (only used if the element’s URI format contains {id})
thumbAlt string (opens new window), null (opens new window)
title string (opens new window), null (opens new window) – The element’s title
titleTranslationDescription string (opens new window), null (opens new window)
titleTranslationKey string (opens new window) – The translation key
totalDescendants integer (opens new window) – The total number of descendants that the element has
trashed boolean (opens new window) – Whether the element has been soft-deleted.
uiLabel string (opens new window)
uiLabelPath string (opens new window)[]
uid string (opens new window), null (opens new window) – The element’s UID
unverifiedEmail string (opens new window), null (opens new window) – Unverified email
updatingFromDerivative boolean (opens new window) – Whether the element is being updated from a derivative element, such as a draft or revision.
uri string (opens new window), null (opens new window) – The element’s URI
uriFormat string (opens new window), null (opens new window) – The URI format used to generate this element’s URL
url string (opens new window), null (opens new window) – The element’s full URL
username string (opens new window), null (opens new window) – Username
validators (opens new window) ArrayObject (opens new window), yii\validators\Validator (opens new window) – All the validators declared in the model.
verificationCode string (opens new window), null (opens new window) – Verification code
verificationCodeIssuedDate DateTime (opens new window), null (opens new window) – Verification code issued date

# active

Type
boolean (opens new window)
Default value
false
Since
4.0.0

Active

View source (opens new window)

# addresses

Type
craft\elements\Address[], null (opens new window)
Default value
null

the user’s addresses

View source (opens new window)

# admin

Type
boolean (opens new window)
Default value
false

Admin

View source (opens new window)

# authError

Type
string (opens new window), null (opens new window)
Default value
null

Auth error

View source (opens new window)

# authKey

Type
string (opens new window), null (opens new window)
Default value
null
Access
Read-only

A key that is used to check the validity of a given identity ID.

View source (opens new window)

# cooldownEndTime

Type
DateTime (opens new window), null (opens new window)
Default value
null

the time when the user will be over their cooldown period

View source (opens new window)

# currentPassword

Type
string (opens new window), null (opens new window)
Default value
null

Current password

View source (opens new window)

# email

Type
string (opens new window), null (opens new window)
Default value
null

Email

View source (opens new window)

# friendlyName

Type
string (opens new window), null (opens new window)
Default value
null

the user’s first name or username

View source (opens new window)

# gqlTypeName

Type
string (opens new window)
Default value
null
Access
Read-only
Since
3.3.0

View source (opens new window)

# groups

Type
craft\models\UserGroup[]
Default value
null

the user’s groups

View source (opens new window)

# hasDashboard

Type
boolean (opens new window)
Default value
false
Since
3.0.4

Whether the user has a dashboard

View source (opens new window)

# hasRoundedThumb

Type
boolean (opens new window)
Default value
null
Access
Read-only
Since
3.5.5

View source (opens new window)

# inheritorOnDelete

Type
self, null (opens new window)
Default value
null

The user who should take over the user’s content if the user is deleted.

View source (opens new window)

# invalidLoginCount

Type
integer (opens new window), null (opens new window)
Default value
null

Invalid login count

View source (opens new window)

# isCredentialed

Type
boolean (opens new window)
Default value
null

whether the user account can be logged into

View source (opens new window)

# isCurrent

Type
boolean (opens new window)
Default value
null

whether this is the current logged-in user

View source (opens new window)

# lastInvalidLoginDate

Type
DateTime (opens new window), null (opens new window)
Default value
null

Last invalid login date

View source (opens new window)

# lastLoginAttemptIp

Type
string (opens new window), null (opens new window)
Default value
null

Last login attempt IP address.

View source (opens new window)

# lastLoginDate

Type
DateTime (opens new window), null (opens new window)
Default value
null

Last login date

View source (opens new window)

# lastPasswordChangeDate

Type
DateTime (opens new window), null (opens new window)
Default value
null

Last password change date

View source (opens new window)

# locked

Type
boolean (opens new window)
Default value
false

Locked

View source (opens new window)

# lockoutDate

Type
DateTime (opens new window), null (opens new window)
Default value
null

Lockout date

View source (opens new window)

# name

Type
string (opens new window)
Default value
null

the user’s full name or username

View source (opens new window)

# newPassword

Type
string (opens new window), null (opens new window)
Default value
null

New password

View source (opens new window)

# password

Type
string (opens new window), null (opens new window)
Default value
null

Password

View source (opens new window)

# passwordResetRequired

Type
boolean (opens new window)
Default value
false

Password reset required

View source (opens new window)

# pending

Type
boolean (opens new window)
Default value
false

Pending

View source (opens new window)

# photo

Type
craft\elements\Asset, null (opens new window)
Default value
null

the user’s photo

View source (opens new window)

# photoId

Type
integer (opens new window), null (opens new window)
Default value
null

Photo asset ID

View source (opens new window)

# preferences

Type
array (opens new window)
Default value
null

the user’s preferences

View source (opens new window)

# preferredLanguage

Type
string (opens new window), null (opens new window)
Default value
null

the user’s preferred language

View source (opens new window)

# preferredLocale

Type
string (opens new window), null (opens new window)
Default value
null

the user’s preferred formatting locale

View source (opens new window)

# remainingCooldownTime

Type
DateInterval (opens new window), null (opens new window)
Default value
null

the remaining cooldown time for this user, if they've entered their password incorrectly too many times

View source (opens new window)

# suspended

Type
boolean (opens new window)
Default value
false

Suspended

View source (opens new window)

# thumbAlt

Type
string (opens new window), null (opens new window)
Default value
null
Access
Read-only
Since
4.0.0

View source (opens new window)

# unverifiedEmail

Type
string (opens new window), null (opens new window)
Default value
null

Unverified email

View source (opens new window)

# username

Type
string (opens new window), null (opens new window)
Default value
null

Username

View source (opens new window)

# verificationCode

Type
string (opens new window), null (opens new window)
Default value
null

Verification code

View source (opens new window)

# verificationCodeIssuedDate

Type
DateTime (opens new window), null (opens new window)
Default value
null

Verification code issued date

View source (opens new window)

# Protected Properties

Property Description
revisionCreatorId integer (opens new window), null (opens new window) – Revision creator ID to be saved
revisionNotes string (opens new window), null (opens new window) – Revision notes to be saved

# Public Methods

Method Description
__call() Calls the named method which is not a class method.
__clone()
__construct()
__get() Returns the value of a component property.
__isset() Checks if a property is set.
__set() Sets the value of a component property.
__toString() Use the full name or username as the string representation.
__unset() (opens new window) Sets a component property to be null.
actions() Returns the available element actions (opens new window) for a given source.
activeAttributes() (opens new window) Returns the attribute names that are subject to validation in the current scenario.
addError() Adds a new error to the specified attribute.