Drupal - Login not redirecting to SSO (external) server login page

Unset the destination before calling drupal_goto():

unset($_GET['destination']);
drupal_goto('PATH/TO/SSO-SERVER-LOGIN-PAGE.ASPX', array('external' => TRUE));

Another option would be to code the redirection logic yourself (brought up as an answer by Dave here).

The problem exists because drupal_goto() is overriding the given path with the destination if the latter is not external (check the function code).

Additionally:

Since you are using the button type the submit handler isn't being invoked (documentation). For my solution to work you would have to change the type to 'submit' or move the redirection logic into the validation handler (by changing '#submit' to '#validate').


//implements hook_form_alter()
function MODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    $form['#action'] = 'PATH/TO/SSO-SERVER-LOGIN-PAGE.ASPX';
  }
}

Tags:

Forms

Users

7