How to redirect user to a specific page after they login if they belong to a certain role?

jini picture jini · Aug 7, 2010 · Viewed 31.5k times · Source

We have certain users in our member list that have a role "vendor" attached to them. All such members are to be redirected to a certain page upon login. How can this be accomplished?

Answer

Felix Eve picture Felix Eve · Nov 23, 2012

There is more than one way to skin this cat... This is my preferred Drupal 7 method:

function hook_user_login(&$edit, $account) {
  $edit['redirect'] = 'node/123';
}