Get user roles in drupal


<?php
global $user;
$role = db_result(db_query(‘SELECT r.name FROM {users_roles} ur LEFT JOIN {role} r ON r.rid=ur.rid WHERE ur.uid=%d LIMIT 1’, $user->uid));
print $role;
?>

<?php
global $user;
print ‘roles: ‘.implode(‘, ‘, $user->roles);
?>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s