Hi, thanks for this module.

I would like you to ask to edit or add a new code snippet in the project page

doing redirection to users is fine, but not a good aproach if you have many user registering all the time
so i'd like to know how do i do assigning to user roles not to user id?

i did something like this, but it's not working:

  global $user_role;
  if ($user_role->rid == 4) {
    // Criação
    return 'blog/2';
  } elseif ($user_role->rid == 9) {
    // Criação
    return 'blog/2';
  } elseif ($user_role->rid == 5) {
    // Vídeo
    return 'blog/3';
  } elseif ($user_role->rid == 10) {
    // Vídeo
    return 'blog/3';
  } elseif ($user_role->rid == 6) {
    // Adm
    return 'blog/4';	
  } elseif ($user_role->rid == 7) {
    // Adm
    return 'blog/4';	
  } elseif ($user_role->rid == 3) {
   // 3d
   return 'blog/5';
  } elseif ($user_role->rid == 8) {
   // 3d
   return 'blog/5';
  } else {
    return 'user';
  }

-I tried using || (OR) but didn't work either, so i did in this lame tons-of-if way
-It works with no error, but it doesn't redirect, i supose it's global $user_role ?

Thanks

Cheers,
-Marco

Comments

pukku’s picture

Hi! In my installation of Drupal, there is no global $user_role. It doesn't make any sense to have such a global anyway, because users have multiple roles; at the very least, they all have role 2 ('authenticated user') in addition to whatever other roles you add to them. You might try the following and see if it works (this is untested):

global $user;
$user_roles = array_keys($user->roles);
if (in_array(4, $user_roles)) {
  return 'blog/2';
}
elseif (in_array(9, $user_roles)) {
  return 'blog/2';
}
...

HTH,
Ricky

ardas’s picture

Status: Active » Closed (fixed)

pukku is absolutely right! you should user $user->roles array.