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

samuraisjakkie’s picture

if 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....

bardill’s picture

global $user;
if(in_array('authenticated user', $user->roles) && arg(0) != 'admin') {
drupal_goto('admin');
}
else
{
drupal_goto('node/340');
}

Hi Sam, this code work only for admin!
(and for more role and redirect?)

Many thanks!
b

samuraisjakkie’s picture

It 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');
}

samuraisjakkie’s picture

did it work for you?