Check a user is admin in Joomla 2.5.x

If you are modifying the edit form for Joomla 2.5.x or other form that requires a need to test if this is a Super Administrator just use the following. Handy if you need to block out certain functionality for different user groups but you still need full access to those options as an administrator.

Joomla 1.5.x world:

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

Joomla 2.5.x world (this will only check for Super Admins):

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

if ($isAdmin) {
  // code here
}

We really shouldn't do it that way though, a check for authorization is better because we can't really determine if a user has that access anyway, so do this:

$user = JFactory::getUser();
if($user->authorise('core.edit', 'com_contact')) {
  echo "Yes, I can edit contacts!";
} else {
  echo "No, I can't edit contacts";<
}
Share on Myspace

Shopping cart

Your cart is empty.

Latest News

CHMOD file only in subdirectory

[FYI] Do this...

Start with directories if you are changing them for the web server first, this will change files too:

$ find images -type d -exec chmod 755 {} +

Then run it again to change files, with the different switch:

$ find images -type f -exec chmod 644 {} +

I recommend adding a recursive (-R) switch along with a verbose output (-v):

$ find images -type f -exec chmod -Rv 644 {} +

You may need to use super permissions to action this. Be warned, this can lock you out.

Joomla 3 - Add language file support for plugins

Do this...

/**
* Load the language file on instantiation.
*
* @var    boolean
* @since  3.1
*/
protected $autoloadLanguage = true;

Generic domains names now available

Here's a full list of "Generic" domain names you probably never thought were available (register at http://hosting.noxidsoft.com):
.technology
.international
.wiki
.tattoo
.university

Login Form