PHP script

margaridacarvalho - March 25, 2009 - 18:27
Project:Login Destination
Version:6.x-2.3
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi!
I'm a newbie in php but by searching and reading in drupal.org I've managed to create my php snippet for login destination. It works fine.
Looks something like this:

global $user;
if (in_array('role1', $user->roles)) {
    return 'node1';

if (in_array('role2', $user->roles)) {
    return 'node2';
}else {
    return '<front>';
}

Now, what i want to do is to redirect a user with more than one role. For example, I want that user with only role1 or only role2 assigned be redirected to the correspondent node, but I want that a user that has been assigned with role1 and role2 be redirected to another node, say node3.
I've tried to add to the code above:

if (in_array('role1', $user->roles)) && if (in_array('role2', $user->roles))  {
    return 'node3';

and later

if (in_array('role1', $user->roles)) AND if (in_array('role2', $user->roles))  {
    return 'node3';

but i'm having no success, it keeps redirecting user with two roles to frontpage.

Probably this is a super simple question, perhaps syntax related but i don't understand much of php...

#1

margaridacarvalho - March 26, 2009 - 09:16
Assigned to:margaridacarvalho» Anonymous
 
 

Drupal is a registered trademark of Dries Buytaert.