How to get current logged in User Objects or Information in Joomla

Hi.. today i share about how to get current logined user Objects and assigned user groups in Joomla CMS.

You can use following member function of JFactory and get current User objects


Ex : Get Current Logined Id, Name, Email and User Name

$userid = $currentuser->id; or $name = JFactory::getUser()->id;
$name = $currentuser->name; or $name = JFactory::getUser()->name;
$email = $currentuser->email; or $email = JFactory::getUser()->email;
$username = $currentuser->username; or $email = JFactory::getUser()->username;

you can get any registered user object from JFactory::getUser() function to pass user id.

Ex: to get 56 th id User Object using following function

$registereduser = JFactory::getUser(56);
$registeredusername = $currentuser->name;
$registereduseremail = $currentuser->email;
$registereduserusername = $currentuser->username;

to get assigned user groups id by using following function.

$usergroup = JFactory::getUser()->groups;

following important member variables are automatically generated on a call to getUser()

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *