API16:JUser/getInstance
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Returns the global User object, only creating it if it doesn't already exist.
Syntax
static getInstance($identifier=0)
| Parameter Name | Default Value | Description |
|---|---|---|
| $identifier | 0 | $id The user to load - Can be an integer or string - If string, it is converted to ID automatically. |
Returns
The User object.
Defined in
libraries/joomla/user/user.php
Importing
jimport( 'joomla.user.user' );
Source Body
static function getInstance($identifier = 0) { static $instances; if (!isset ($instances)) { $instances = array (); } // Find the user id if (!is_numeric($identifier)) { jimport('joomla.user.helper'); if (!$id = JUserHelper::getUserId($identifier)) { JError::raiseWarning('SOME_ERROR_CODE', 'JUser::_load: User '.$identifier.' does not exist'); $retval = false; return $retval; } } else { $id = $identifier; } if (empty($instances[$id])) { $user = new JUser($id); $instances[$id] = $user; } return $instances[$id]; }
[Edit See Also] SeeAlso:JUser/getInstance
Examples
<CodeExamplesForm />
