Active
Project:
Login Destination
Version:
6.x-1.1
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
10 May 2010 at 13:40 UTC
Updated:
27 Jun 2010 at 15:19 UTC
Right now I'm using Login Destination with these settings:
Redirection Conditions - Always
Destination URL settings- PHP Snippet
global $user;
if (in_array('abc',$user->roles)) $path = 'abc';
elseif (in_array('def',$user->roles)) $path = 'def';
elseif (in_array('etc',$user->roles)) $path = 'etc';
else $path = '';
return $path;
Which works perfectly. The only problem is I want the admin role only to be redirected to the last visited page.
Of course when I click Preserve Destination, it overrides my PHP snippets (which is understandable) but how can I keep this functionality for select roles. Any suggestions?
Comments
Comment #1
3cwebdev commentedYou could add code to your PHP snippet to check if the user belongs to the specified role and, if so, pull the destination out of the URL and perform the redirect through your snippet.
Comment #2
macandrow commentedWould I add this code to the current php snippet I have or place elsewhere?
I used to have the snippet below to redirect to last page in my template.php:
// This snippet returns the user to their last visited page after they've logged in.
function screen_menu_item_link($link) {
if ($link['title']=='Log In') {
if (empty($link['localized_options'])) {
$link['localized_options'] = array();
}
//set the destination, for different destinations for different users, work it out here
$destination = drupal_get_destination();
//Merge in the query with current localized options
$link['localized_options'] += array(
'query' => $destination,
);
}
return l($link['title'], $link['href'], $link['localized_options']);
}
Would you be able to tell me, is there a part of the code above that I can place in my current snippet?
Comment #3
tallsimon commentedtry this
return $_REQUEST['q'];