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

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';
}

For Drupal 7

Action --> admin/config/system/actions - Redirect to URL

then enable your trigger module

Trigger --> /admin/structure/trigger/node

if your are trying to login redirect just follow this(select user tab in the page)

go to --> admin/structure/trigger/user

then Trigger: After a user has logged in

choose an action -->Redirect to URL and assign.

Then clear the cache.

It will work for you!


You can define actions and triggers in Drupal:

Action(admin/settings/actions) - Redirect to a specific page

Trigger (admin/build/trigger/user) - After user has logged in

Try this.

EDIT (see comments):

Create a small module to check on a user's login process what role he has and then redirect if neccesary. drupal_goto => redirect-function in drupal

hook_user =>triggers on user operations

And for the user's roles:

GLOBAL $user;
$roles = $user->roles;
$vendor = in_array('vendor', $roles);

$vendor then holds a true/false value will decide to redirect or not.

If you don't know how to do this, just post here and I'll write the module for you. But this would be a good practice for writing future drupa modules for you perhaps. :)