How to get the currently logged in user's role in Drupal 7?

Ek Kosmos picture Ek Kosmos · Mar 8, 2011 · Viewed 32.7k times · Source

How to get the currently logged in user's role in Drupal 7 ? Do you know a simple way of accomplish this ? Is there some drupal core functions for this?

Answer

Artusamak picture Artusamak · Mar 8, 2011

You can access to the user roles by just using this PHP snippet:

<?php $GLOBALS['user']->roles; ?>