User

Extends CMSObject

User class. Handles all application interaction with a user

since

1.7.0

package

Application

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed properties = null) : mixed
inherited
since

1.7.0

Arguments

properties

mixedEither and associative array or another object to set the initial properties of the object.

Response

mixed

__sleep

Method to allow serialize the object with minimal properties.

__sleep() : array
since

3.6.0

Response

arrayThe names of the properties to include in serialization.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

1.7.0

deprecated

3.1.4 Classes should provide their own __toString() implementation.

Response

stringThe classname.

__wakeup

Method to recover the full object on unserialize.

__wakeup() : void
since

3.6.0

authorise

Method to check User object authorisation against an access control object and optionally an access extension object

authorise(string action, string assetname = null) : bool
since

1.7.0

Arguments

action

stringThe name of the action to check for permission.

assetname

stringThe name of the asset on which to perform the action.

Response

boolTrue if authorised

bind

Method to bind an associative array of data to a user object

bind(array &array) : bool
since

1.7.0

Arguments

array

arrayThe associative array to bind to the object

Response

boolTrue on success

clearAccessRights

Clears the access rights cache of this user

clearAccessRights() : void
since

3.4.0

def

Sets a default value if not already assigned

def(string property, mixed default = null) : mixed
inherited
since

1.7.0

Arguments

property

stringThe name of the property.

default

mixedThe default value.

Response

mixed

defParam

Method to set a default parameter if it does not exist

defParam(string key, mixed value) : mixed
since

1.7.0

Arguments

key

stringParameter key

value

mixedParameter value

Response

mixedSet parameter value

delete

Method to delete the User object from the database

delete() : bool
since

1.7.0

Response

boolTrue on success

get

Returns a property of the object or the default value if the property is not set.

get(string property, mixed default = null) : mixed
inherited
since

1.7.0

see CMSObject::getProperties()

Arguments

property

stringThe name of the property.

default

mixedThe default value.

Response

mixedThe value of the property.

getAuthorisedCategories

Method to return a list of all categories that a user has permission for a given action

getAuthorisedCategories(string component, string action) : array
since

1.7.0

Arguments

component

stringThe component from which to retrieve the categories

action

stringThe name of the section within the component from which to retrieve the actions.

Response

arrayList of categories that this group can do this action to (empty array if none). Categories must be published.

getAuthorisedGroups

Gets an array of the authorised user groups

getAuthorisedGroups() : array
since

1.7.0

Response

array

getAuthorisedViewLevels

Gets an array of the authorised access levels for the user

getAuthorisedViewLevels() : array
since

1.7.0

Response

array

getError

Get the most recent error message.

getError(int i = null, bool toString = true) : string
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Arguments

i

intOption error index.

toString

boolIndicates if Exception objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Response

arrayArray of error messages.

getInstance

Returns the global User object, only creating it if it doesn't already exist.

getInstance(int identifier) : \Joomla\CMS\User\User
static deprecated
since

1.7.0

deprecated

5.0 Load the user service from the dependency injection container or via $app->getIdentity()

Arguments

identifier

intThe primary key of the user to load (optional).

Response

\Joomla\CMS\User\UserThe User object.

getParam

Method to get a parameter value

getParam(string key, mixed default = null) : mixed
since

1.7.0

Arguments

key

stringParameter key

default

mixedParameter default value

Response

mixedThe value or the default if it did not exist

getProperties

Returns an associative array of object properties.

getProperties(bool public = true) : array
inherited
since

1.7.0

see CMSObject::get()

Arguments

public

boolIf true, returns only the public properties.

Response

array

getTable

Method to get the user table object

getTable(string type = null, string prefix = 'JTable') : \Joomla\CMS\Table\Table
static

This function uses a static variable to store the table name of the user table to instantiate. You can call this function statically to set the table name if needed.

note

At 4.0 this method will no longer be static

since

1.7.0

Arguments

type

stringThe user table name to be used

prefix

stringThe user table prefix to be used

Response

\Joomla\CMS\Table\TableThe user table object

getTimezone

Method to get the user timezone.

getTimezone() : \DateTimeZone

If the user didn't set a timezone, it will return the server timezone

since

3.7.0

Response

\DateTimeZone

load

Method to load a User object by user id number

load(mixed id) : bool
since

1.7.0

Arguments

id

mixedThe user id of the user to load

Response

boolTrue on success

save

Method to save the User object to the database

save(bool updateOnly = false) : bool
since

1.7.0

throws

\RuntimeException

Arguments

updateOnly

boolSave the object only if not a new user Currently only used in the user reset password method.

Response

boolTrue on success

set

Modifies a property of the object, creating it if it does not already exist.

set(string property, mixed value = null) : mixed
inherited
since

1.7.0

Arguments

property

stringThe name of the property.

value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setError

Add an error message.

setError(string error) : void
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Arguments

error

stringError message.

setLastVisit

Pass through method to the table for setting the last visit date

setLastVisit(int timestamp = null) : bool
since

1.7.0

Arguments

timestamp

intThe timestamp, defaults to 'now'.

Response

boolTrue on success.

setParam

Method to set a parameter

setParam(string key, mixed value) : mixed
since

1.7.0

Arguments

key

stringParameter key

value

mixedParameter value

Response

mixedSet parameter value

setParameters

Method to get the user parameters

setParameters(object params) : void
since

1.7.0

Arguments

params

objectThe user parameters object

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed properties) : bool
inherited
since

1.7.0

see CMSObject::set()

Arguments

properties

mixedEither an associative array or another object.

Response

bool

Properties

isRoot

A cached switch for if this user has root access rights.

since

1.7.0

Type(s)

bool

id

Unique id

since

1.7.0

Type(s)

int

name

The user's real name (or nickname)

since

1.7.0

Type(s)

string

username

The login name

since

1.7.0

Type(s)

string

email

The email

since

1.7.0

Type(s)

string

password

MD5 encrypted password

since

1.7.0

Type(s)

string

password_clear

Clear password, only available when a new password is set for a user

since

1.7.0

Type(s)

string

block

Block status

since

1.7.0

Type(s)

int

sendEmail

Should this user receive system email

since

1.7.0

Type(s)

int

registerDate

Date the user was registered

since

1.7.0

Type(s)

string

lastvisitDate

Date of last visit

since

1.7.0

Type(s)

string

activation

Activation hash

since

1.7.0

Type(s)

string

params

User parameters

since

1.7.0

Type(s)

\Joomla\Registry\Registry

groups

Associative array of user names => group ids

since

1.7.0

Type(s)

array

guest

Guest status

since

1.7.0

Type(s)

int

lastResetTime

Last Reset Time

since

3.0.1

Type(s)

string

resetCount

Count since last Reset Time

since

3.0.1

Type(s)

int

requireReset

Flag to require the user's password be reset

since

3.2

Type(s)

int

_params

User parameters

since

1.7.0

Type(s)

\Joomla\Registry\Registry

_authGroups

Authorised access groups

since

1.7.0

Type(s)

array

_authLevels

Authorised access levels

since

1.7.0

Type(s)

array

_authActions

Authorised access actions

since

1.7.0

Type(s)

array

_errorMsg

Error message

since

1.7.0

Type(s)

string

instances

User instances container.

static
since

1.7.3

Type(s)

array

_errors

An array of error messages or Exception objects.

inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Type(s)

array