hi
this is a simple and crude php code to redirect the user according to roles in drupal
this can be used in drupal hook_user function or panels pages to redirect the user
this is a simple and crude php code to redirect the user according to roles in drupal
this can be used in drupal hook_user function or panels pages to redirect the user
<?php
global $user;
//consider two roles moderator and regular user
//moderator role rid is 2
//regular user role rid is 4
if($user){
//roles item is array
if($user->roles[2]){// if user has a role moderator
//do this
drupal_goto("user/moderater-panel");// redirecting
}elseif ($user->roles[4]){ // user user have role regular user
drupal_goto("user/regular-panel");// redirecting
}else{ // if the user have other roles then above roles do this
//do smothing
}
}
No comments:
Post a Comment