Check a user is admin in Joomla

Check User in joomla 1.5

$user =& JFactory::getUser();
if($user->usertype == "Super Administrator" || $user->usertype == "Administrator") {
echo 'You are an Administrator';
} else {
echo 'You are not Administrator';
}

Check User in Joomla 2.5 & 3.0

$user = JFactory::getUser();
$isAdmin = $user->get('isRoot');
if ($isAdmin) {
echo 'You are an Administrator';
}
else  {
echo 'You are not Administrator';
}

OR

function isUserSuperAdmin()
{
  $user = JFactory::getUser();
  return $user->get('isRoot');
}    

if (isUserSuperAdmin()) 
{
  echo 'You are an Administrator';
}
else  {
  echo 'You are not Administrator';
}
Advertisements
Categories: Joomla | Tags: , , , , , , | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: