For example, there is page called user-serach. I want to redirect to a user-search page, when the user of some ROLE 'user-search-role'.
For this, you need to implement, hook_user_login(&$edit, $account).
/**
- Implements hook_user_login().`
*/
function hook_user_login(&$edit, $account) {
// Do not redirect when the user is resetting her/his password.
if (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset') {
if (in_array('user-search-role', $account->roles)) {
drupal_goto('user-serach');
}
} }