Closed (fixed)
Project:
Login Destination
Version:
5.x-1.0
Component:
Documentation
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
29 May 2007 at 18:38 UTC
Updated:
27 Jul 2007 at 15:53 UTC
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
Comment #1
pukku commentedHi! 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):
HTH,
Ricky
Comment #2
ardas commentedpukku is absolutely right! you should user $user->roles array.