Im trying to redirect the user to different pages on login, first-time login and registration. I used the Login Destination module but it only has the option to redirect the user to one page on registration login and first-time login. Is there another way of doing this?
I have not tested this but from the documentation page:
There are no separate triggers for login and registration; instead you can differentiate them by specifying the pages that a user comes from:
- user - the user login form.
- user/register - the user registration form.
- user/*/edit - one-time login link, after the user has set the password.
- other - the login block or login forms embedded by other modules.
It looks like you can specify both three options you ask for.
Here is a simple approach: - create a simple module, implement hook_form_alter and hook_user_login:
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
// dpm($form_id);
// dpm($form);
if ('user_register_form' == $form_id) {
$form['#submit'][] = 'my_custom_register_callback';
}
}
function my_custom_register_callback($form, &$form_state) {
// do some logic, redirect;
}
function MYMODULE_user_login(&$edit, $account) {
if (null == $account->access /* this user has not been logged in before, he/she is being logged in the first time */) {
// redirect him/her, eg. drupal_goto('SOME_URL');
}
else {
// redirect him/her to another URL;
}
}