3

As my question implies what i want, i used google to search through the web to get correct answer though simple about how to verify if current logged in user is super user or not in both joomla 2.5 and 3 versions. I found these codes -

$user = JFactory::getUser();
$isroot = $user->get('isRoot');

if $isroot is 1 then the user is super user. Does it appropriate and error free all the ways??

7

That will work if isRoot has been set. But, it requires a call to JUser::authorise() having been completed first. This snippet would work at all times:

$user = JFactory::getUser();

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

  • Does it also return 1 if current user is administrator not super user? So concern is have to verify only super user. – dev-m Apr 28 '14 at 1:13
  • No, that code snippet will check what is mapped to the "Super User" permission in the global configuration. If you don't pass a second parameter to JUser::authorise(), then it checks the permissions at the global level. – Michael Apr 28 '14 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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