User
Extends CMSObjectUser class. Handles all application interaction with a user
since |
1.7.0 |
---|---|
package |
Joomla CMS |
Methods
__construct
Constructor activating the default information of the language
__construct( identifier) :
since |
1.7.0 |
---|
Arguments
- identifier
int
The primary key of the user to load (optional).
Response
mixed
__sleep
Method to allow serialize the object with minimal properties.
__sleep() : mixed||string|int
since |
3.6.0 |
---|
Response
array<string|int, mixed>
The names of the properties to include in serialization.
__toString
Magic method to convert the object to a string gracefully.
__toString() :
since |
1.7.0 |
---|---|
deprecated |
4.3 will be removed in 6.0 Classes should provide their own __toString() implementation. |
Response
string
The classname.
__wakeup
Method to recover the full object on unserialize.
__wakeup() :
since |
3.6.0 |
---|
Response
void
authorise
Method to check User object authorisation against an access control object and optionally an access extension object
authorise( action, assetname = null) :
since |
1.7.0 |
---|
Arguments
- action
string
The name of the action to check for permission.- assetname
string
The name of the asset on which to perform the action.
Response
bool
True if authorised
bind
Method to bind an associative array of data to a user object
bind(mixed||string|int &array) :
since |
1.7.0 |
---|
Arguments
- array
array<string|int, mixed>
The associative array to bind to the object
Response
bool
True on success
clearAccessRights
Clears the access rights cache of this user
clearAccessRights() :
since |
3.4.0 |
---|
Response
void
def
Sets a default value if not already assigned
def( property, default = null) :
since |
1.7.0 |
---|---|
deprecated |
4.3.0 will be removed in 6.0 Defining dynamic properties should not be used anymore |
Arguments
- property
string
The name of the property.- default
mixed
The default value.
Response
mixed
defParam
Method to set a default parameter if it does not exist
defParam( key, value) :
since |
1.7.0 |
---|
Arguments
- key
string
Parameter key- value
mixed
Parameter value
Response
mixed
Set parameter value
delete
Method to delete the User object from the database
delete() :
since |
1.7.0 |
---|
Response
bool
True on success
get
Returns a property of the object or the default value if the property is not set.
get( property, default = null) :
since |
1.7.0 |
---|---|
see | CMSObject::getProperties() |
deprecated |
4.3.0 will be removed in 6.0 Create a proper getter function for the property |
Arguments
- property
string
The name of the property.- default
mixed
The default value.
Response
mixed
The value of the property.
getAuthorisedCategories
Method to return a list of all categories that a user has permission for a given action
getAuthorisedCategories( component, action) : mixed||string|int
since |
1.7.0 |
---|
Arguments
- component
string
The component from which to retrieve the categories- action
string
The name of the section within the component from which to retrieve the actions.
Response
array<string|int, mixed>
List 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() : mixed||string|int
since |
1.7.0 |
---|
Response
array<string|int, mixed>
getAuthorisedViewLevels
Gets an array of the authorised access levels for the user
getAuthorisedViewLevels() : mixed||string|int
since |
1.7.0 |
---|
Response
array<string|int, mixed>
getError
Get the most recent error message.
getError( i = null, toString = true) :
since |
1.7.0 |
---|---|
deprecated |
3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getError |
Arguments
- i
int
Option error index.- toString
bool
Indicates if Exception objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : mixed||string|int
since |
1.7.0 |
---|---|
deprecated |
3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getErrors |
Response
array<string|int, mixed>
Array of error messages.
getInstance
Returns the global User object, only creating it if it doesn't already exist.
getInstance( identifier) : \Joomla\CMS\User\User
since |
1.7.0 |
---|---|
deprecated |
4.3 will be removed in 6.0 Load the user service from the dependency injection container or via $app->getIdentity() Example: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($id) |
Arguments
- identifier
int
The primary key of the user to load (optional).
Response
User
The User object.
getParam
Method to get a parameter value
getParam( key, default = null) :
since |
1.7.0 |
---|
Arguments
- key
string
Parameter key- default
mixed
Parameter default value
Response
mixed
The value or the default if it did not exist
getProperties
Returns an associative array of object properties.
getProperties( public = true) : mixed||string|int
since |
1.7.0 |
---|---|
see | CMSObject::get() |
deprecated |
4.3.0 will be removed in 6.0 Create a proper getter function for the property |
Arguments
- public
bool
If true, returns only the public properties.
Response
array<string|int, mixed>
getTable
Method to get the user table object
getTable( type = null, prefix = 'JTable') : \Joomla\CMS\Table\Table
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
string
The user table name to be used- prefix
string
The user table prefix to be used
Response
Table
The 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( id) :
since |
1.7.0 |
---|
Arguments
- id
mixed
The user id of the user to load
Response
bool
True on success
save
Method to save the User object to the database
save( updateOnly = false) :
since |
1.7.0 |
---|---|
throws |
|
Arguments
- updateOnly
bool
Save the object only if not a new user Currently only used in the user reset password method.
Response
bool
True on success
set
Modifies a property of the object, creating it if it does not already exist.
set( property, value = null) :
since |
1.7.0 |
---|---|
deprecated |
4.3.0 will be removed in 6.0 Create a proper setter function for the property |
Arguments
- property
string
The name of the property.- value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setError
Add an error message.
setError( error) :
since |
1.7.0 |
---|---|
deprecated |
3.1.4 will be removed in 6.0 Will be removed without replacement Throw an Exception instead of using setError |
Arguments
- error
string
Error message.
Response
void
setLastVisit
Pass through method to the table for setting the last visit date
setLastVisit( timestamp = null) :
since |
1.7.0 |
---|
Arguments
- timestamp
int
The timestamp, defaults to 'now'.
Response
bool
True on success.
setParam
Method to set a parameter
setParam( key, value) :
since |
1.7.0 |
---|
Arguments
- key
string
Parameter key- value
mixed
Parameter value
Response
mixed
Set parameter value
setParameters
Method to get the user parameters
setParameters( params) :
since |
1.7.0 |
---|
Arguments
- params
object
The user parameters object
Response
void
setProperties
Set the object properties based on a named array/hash.
setProperties( properties) :
since |
1.7.0 |
---|---|
see | CMSObject::set() |
deprecated |
4.3.0 will be removed in 6.0 Create a proper setter function for the property |
Arguments
- properties
mixed
Either an associative array or another object.
Response
bool
Properties
_errors
An array of error messages or Exception objects.
since |
1.7.0 |
---|---|
deprecated |
3.1.4 JError has been deprecated |
Type(s)
array<string|int, mixed>
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
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)
Registry
groups
Associative array of user names => group ids
since |
1.7.0 |
---|
Type(s)
array<string|int, mixed>
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)
Registry
_authGroups
Authorised access groups
since |
1.7.0 |
---|
Type(s)
array<string|int, mixed>
_authLevels
Authorised access levels
since |
1.7.0 |
---|
Type(s)
array<string|int, mixed>
_authActions
Authorised access actions
since |
1.7.0 |
---|
Type(s)
array<string|int, mixed>
_errorMsg
Error message
since |
1.7.0 |
---|
Type(s)
string
instances
User instances container.
since |
1.7.3 |
---|
Type(s)
array<string|int, mixed>
aid
The access level id
since |
4.3.0 |
---|---|
deprecated |
4.4.0 will be removed in 6.0 as this property is not used anymore |
Type(s)
int