Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Sorry for this easy question. I use this code to redirect admin role user
global $user;
if(in_array('authenticated user', $user->roles) && arg(0) != 'admin') {
drupal_goto('admin');
}
How to merge with this below (for editor role)
global $user;
if(in_array('authenticated user', $user->roles) && arg(0) != 'editor') {
drupal_goto(node/340');
}
I want only one script of code.
Many thanks.
b
Comments
Comment #1
samuraisjakkie CreditAttribution: samuraisjakkie commentedif there are only 2 permissions would it not be simply
global $user;
if(in_array('authenticated user', $user->roles) && arg(0) != 'admin') {
drupal_goto('admin');
}
else
{
drupal_goto(node/340');
}
or if there are more than the 2 permission types use elseif....
Comment #2
bardill CreditAttribution: bardill commentedHi Sam, this code work only for admin!
(and for more role and redirect?)
Many thanks!
b
Comment #3
samuraisjakkie CreditAttribution: samuraisjakkie commentedIt will be just a basic, if, elseif statement.....
the login destination page below has loads of snippets you could use.
http://drupal.org/node/418488
global $user;
if(in_array('authenticated user', $user->roles) && arg(0) != 'admin') {
drupal_goto('admin');
}
elseif (in_array('authenticated user', $user->roles) && arg(0) != 'role1') {
drupal_goto('what ever page you want');
}
elseif (in_array('authenticated user', $user->roles) && arg(0) != 'role2') {
drupal_goto('what ever page you want');
}
else
{
drupal_goto('node/340');
}
Comment #4
samuraisjakkie CreditAttribution: samuraisjakkie commenteddid it work for you?