You created a form or want to redirect one of Drupal’s form to another page based on a value/logic, you want to use hook_form_alter() to add your own submit function that runs when the form is submitted. You will be able to see the submitted form values and redirect as needed. Its a ‘simple’ 2-step process if you already have a custom module going.
For this case, say we want to redirect the user to a specific page after logging in (there are modules that handle this, but this is just a demo).
// add your own submit function to drupal's user_login form
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'user_login') {
// $form['#submit'] is an array that contains all functions to run when form is submitted
$form['#submit'][] = 'mymodule_login_redirect';
}
}
// this is the function you entered to run above
function mymodule_login_redirect($form, &$form_state) {
$form_state['redirect'] = 'node/123'; // node to redirect to
}
Please do not use drupal_goto() or another method. It may looks like it works, but its bad form and doesn’t allow other submit functions to run if they run after yours.