Login not redirecting to SSO (external) server login page I'm trying to replace Drupal authentication with the authentication from a SSO server, in a scenario discussed here. I'm trying to modify the login_block (on "Homepage" as well as "Access Denied" page), and login_block_form (at mysite.com/user/login). I did reset the default "Log in" button and replaced it with "SSO Log in" button, and on its #submit, using drupal_goto, I'm trying to redirect it to SSO server Login page. But, I'm still getting redirected to mysite.com/node?destination=node. I'm not able to figure out what the problem is. And inputs would be appreciated.

function MODULE_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    // Add a button to form, used to login to SSO
        $form['foo'] = array(
            '#type' =&gt; 'button',
            '#value' =&gt; t('SSO Log in'),
            '#submit' =&gt; array('MODULE_user_login_foo_submit'),
            '#limit_validation_errors' =&gt; array(),
        );
        // unset the current default login button of Drupal
        unset ($form['actions']['submit']);
  }
}

function MODULE_user_login_foo_submit($form, &amp;$form_state) {
  drupal_goto('PATH/TO/SSO-SERVER-LOGIN-PAGE.ASPX', array('external' =&gt; TRUE));
}
Unset the destination before calling drupal_goto():

unset($_GET['destination']);
drupal_goto('PATH/TO/SSO-SERVER-LOGIN-PAGE.ASPX', array('external' =&gt; 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').