joomla development, find out role of user

Posted on 2007-10-01
Last Modified: 2012-08-14
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.
Question by:rukiman
    1 Comment
    LVL 11

    Accepted 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,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now