Take the 2-minute tour ×
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It's 100% free, no registration required.

To determine whether the visitor is a guest, we use something like this :

if ($user->guest) {
echo 'Hello, guest!';

Now, if i want to determine whether the visitor is a registered SuperUser (Administrator) or not, what would be the code for that?

I have some external PHP files which i don't want to be accessible by anyone except the SuperUsers of my Joomla Website. Just trying to secure the files by importing Joomla CMS.

share|improve this question
Funny I needed this last night and just googled till I found a solution. In my case I was overriding the output from RSFiles so the tool bar only shows up for admins. –  Brian Peat Jun 6 '14 at 16:33

4 Answers 4

these codes will determine if current logged in user is super user or not -

$user = JFactory::getUser();
$isroot = $user->authorise('core.admin');

that code will check what is mapped to the "Super User" permission in the global configuration and not in only component level. Check it yourself comparing with other ways.

share|improve this answer
The explanation in this answer is a bit weak, but I think core.admin is a better permission to check than core.edit. –  Brilliand Jun 6 '14 at 16:07
I disagree. core.admin is the permission uses to control access to the global config, so it is the appropriate way to check if a user is the super admin. If you check for the group 8 like the accepted answer, if Joomla! ever decides to randomize it for security sake, your script will break. Always code with change in mind. Unless you never intend to upgrade. –  Mathew Lenning Jun 8 '14 at 15:06
This is clearly the best match for a SuperUser check. It will check both for the failsafe, and for the SuperUser permission. github.com/joomla/joomla-cms/blob/staging/libraries/joomla/user/… The other alternative is $user->get('isRoot') which assumes that authorise has already been used to populate the isRoot state. The isRoot can be used directly as it's a protected property. github.com/joomla/joomla-cms/blob/staging/administrator/… –  Peter Wiseman Jun 10 '14 at 4:53

To determine the "Super User" status you have to check $user->isRoot. This property is set after the first authorise check is done and the user is detected to be super admin.

However usually you indeed better want to check if the user has certain permissions like described on the other answers.

share|improve this answer
This assumes $user->authorise() has already been called by something else to populate the isRoot property. Also note that the isRoot property is protected so needs to be access via $user->get('isRoot'). –  Peter Wiseman Jun 10 '14 at 4:54

Try this,

$user  = JFactory::getUser();

$user_groups = $user->groups;


This will return an array, By default Joomla Admin users Super admin (Groups 8) and Administrator (Group 7).

You can check the array have any of these values then it should be Admin user , If you're created Custom User group then you have to check #__usergroups parent Id too.

Hope it helps..

share|improve this answer

You can use a condition to refuse anywho is not in a specific group.

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

if (in_array(8, $groups)):

 //only enter it the user is in the group 8 (Super-Administrator)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.