Redirect By Role & First Time Redirect By Role

rajasekharan - June 20, 2008 - 12:04
Project:Login Destination
Version:5.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I'd like this feature implemented in logindestination:

1. The ability to redirect a user to a particular node depending on what role they belong to.
2. The ability to redirect a user to a particular node the first time they log in depending on the role they belong to.
Regards,
Raj

#1

perandre - November 6, 2008 - 21:45

I'd love to see #1 in Drupal 6 version.

#2

butler360 - November 7, 2008 - 00:57

I'd also like to see #1 in the 6.x version. It's actually what I downloaded the module for.

#3

Sakrecoer - February 18, 2009 - 18:21

here is how to do it in both 5.x and 6.x (taken from: http://drupal.org/node/179981 ) :

paste this in the URL window of the login destination administration menu, having ticked the "PHP snippet option:

global $user;
if (in_array('special users', $user->roles)) {
    return 'node/5'; // Custom page for 'special users'
}
else {
    return '<front>'; //User does not have 'special users' role.
}

replace special user with the role name
replace node/5 with your desired url

copy paste this:

if (in_array('special users', $user->roles)) {
    return 'node/5'; // Custom page for 'special users'
}

for all the roles you want to give special redirections to

"thank you drupal community!!!"

/reSet Sakrecoer the hyper-n00b

#4

abamarus - February 24, 2009 - 15:45

OK - looking at the examples means I'm learning about how this code snippet thing works. Can you very helpful guys point me in the right dorection for working out what I want to do....

Basically I want to redirect based on weather the user has filled in their profile (which uses the content profile module). If they have then I want to go to a particular node so I return 'node/42' ... that's cool. It is how to test for if the profile node exists that I am stuck on. Any tips would be appreciated (or even a snippet that you use and work to do the same thing)

Many thanks

#5

asak - February 27, 2009 - 15:30

Hey guys - any idea on the second issue Raj has pointed?

2. The ability to redirect a user to a particular node the first time they log in depending on the role they belong to.

I can't seem to find how to do this...

#6

volocuga - May 26, 2009 - 09:45

It does not work for names with non-latin characters.I tried to replace role name with role ID but no success :(

Please help :)

#7

asak - June 23, 2009 - 16:47

volocuga: i've noticed multiple issues with non-latin characters in roles, i found it's always best to stick with the latin chars...

#8

mgladding - July 8, 2009 - 22:45

Awesome! Perfect!

Thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.