Friday, February 6, 2009

How to find what roles user has in Drupal

User object in Drupal has a roles array and all you have to do is to check if this array has the role you want.

Here is an example:

<?php
global $user;
$user->roles[ "ROLE_ID" ] = "ROLE_NAME";

// You can traverse through the array
// and check if user has the role you want
foreach($user->roles as $rid => $role){
if($role == "role_i_want"){
// Do something
}
}
?>

Saturday, January 31, 2009

Drupal Howto's resouce

Here I will be posting my Drupal howto's and tips. Also, here you can find Drupal tutorials, custom modules and more.

Stay tuned!