• 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.
0
rukiman
Asked:
rukiman
1 Solution
 
siliconbritCommented:

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();
  $type=$user->usertype;

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

  http://api.joomla.org/Joomla-Framework/User/JUser.html

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

  http://www.jlleblanc.com/index.php?option=com_content&task=view&id=48

Good Luck,
0

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