0
votes

I need to forward users with a specific role "roleA" after they login to the website.

I've tried to use

if ($form_id == 'user_login') { global $user; ... }

However this is before the user insert nickname and pass, therefore the role is always anonymous at this point.

What's the form_id of the login submission form instead ? I would prefer to not install additional modules for this simple forwarding.

thanks

2

2 Answers

1
votes

hook_user, $op = login. But you can use just Rules module, there's event - user login, filter for user role = "roleA", action - redirect to page.

0
votes

I think you are in the right track, but how are you making the redirection? This way should work:

function custom_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_login':
        $form['#redirect'] = 'your-page';
      break;
  }
}

Being 'your-page' the alias of the page. Or also 'node/22' if not alias is being used.

And "custom" the name of the module as you know.

http://drupal.org/node/134000