Reputation: 33
I have a page on my website that I want to redirect users to different pages based on their role.
I tried to make a module to put mymodule_init()
to redirect users.
I check with arg(0)
my page but cannot figure out how to redirect user based on role.
How do I?
Upvotes: 1
Views: 272
Reputation: 1553
You can access the $user
variable since its a global variable by putting
global $user;
At the beginning of your logic. Then you can check the user role with something like:
if (in_array('myrole', $user->roles)) {
drupal_goto('page');
}
Upvotes: 1