I want to redirect all users but the admin to the Web File Manager.

For this reason I have set the destination path field (Always) to "webfm".
The Redirect condition field I have set to "PHP snippet" and entered the following code:

global $user;
return ($user->uid != 1);

Despite this setting also the admin (uid=1) user is always redirected to "webfm" after login.

What have I done wrong?

Thanks for any help.
Christian

Comments

nathan573’s picture

The problem here seems to be that at the time the redirection condition php snippet is run the user is still perceived by Drupal as anonymous. I found this out by sending myself an email with the output of the $user array from the redirect condition php snippet. The redirect condition would be a lot more useful if it had access to the user info for the user that is logging in. I'm not sure if there is an easy work-around. Dmitry, do you have any ideas for us? Thank you.

nathan573’s picture

The work around for this is to put all the logic in the "URL destination settings" php snippet. Set the "Redirection condition" to "Always" and then create the php snippet that defines the path taken upon login.

Here's a snippet I use to redirect a user to a terms page if they don't already have a variable set indicating they've agreed to the terms, otherwise I take them to their user page.

global $user;

// if user TOS variable is not set, redirect to Terms page
$terms_check = variable_get('terms-agreement1-'.$user->uid, 0);

if ($terms_check==0) {
   $redirect="terms-and-conditions";
} else {
   $redirect="user";
}

return $redirect;
ddrozdik’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Version 5 of the module is not supported anymore.