Redirection per role

data18 - July 11, 2008 - 15:11
Project:Login Destination
Version:5.x-1.0
Component:User interface
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

is it possible to make a redirection per role?
Thanks & regards
Alexander

#1

DonCoryon - July 22, 2008 - 02:00

Yes

  global $user;
  if (in_array('admin', $user->roles)) {
    // Redirect the Administrator
    return 'admin';
  }  elseif (in_array('unverified', $user->roles)) {
    // Redirect Unverified
    return 'node/4';
} else {
    return 'node';
  }

#2

jdlind38 - November 10, 2008 - 16:17

How would you redirect users of a specific role and insert their user id in the url?? For example, user/[USER ID]/foo... Basically, I'm looking for the array to return 'user/'.$user->uid.'/my/example'

#3

DonCoryon - November 11, 2008 - 17:24

Use this snippet to print the user id.

<?php
global $user;
print
$user->uid;
?>

If you wanted to return a link for a logged in user you could use something like this

<a href="user/<?php
global $user;
print
$user->uid;
?>
">My Account</a>

--
Need professional help with your Drupal project? Goodwin Solutions

 
 

Drupal is a registered trademark of Dries Buytaert.