Joomla - Get user id

To get user id in joomla use,

$user =& JFactory::getUser();
$userId = $user->get( 'id' );

You can also get User details like,
$user =& JFactory::getUser();
$userId = $user->username;  // Returns username
$userId = $user->name;        // Returns real name
$userId = $user->id;             // Returns id

Comments

Popular posts from this blog

Ghostscript Installation and Configuration in Windows 7