• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 714
  • Last Modified:

joomla development, find out role of user

I am creating a component for joomla. Now how can I work out whether the current user has administrator's role so I can display a "delete" link in the front end of my component?
Sample code would be helpful.
1 Solution

The role of the current user is held in the JUser class, in the variable '$usertype'.  The value of this variable can be one of an enumerated list including "Super Administrator", "Administrator", "Editor" etc.  The same values that are on the drop down list when you create a user.

You can query the current role using the JUser class:

  $user =& JFactory::getUser();

For more information on the JUser class, you can visit the Joomla! website, and read about the JUser class in the API:


As ever, someone has written a short guide on the subject at:


Good Luck,

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now