diff --git a/tfa.module b/tfa.module
index c69c4ec..939d165 100644
--- a/tfa.module
+++ b/tfa.module
@@ -246,7 +246,10 @@ function tfa_form_alter(&$form, &$form_state, $form_id) {
         // TFA form so the last handler in the order must be
         // tfa_login_form_redirect(). Other modules may alter the tfa_redirect
         // options element as needed to set the destination after TFA.
-        $key = array_search('user_login_submit', $form['#submit']);
+        $key = 0;
+        if (isset($form['#submit'])) {
+          $key = array_search('user_login_submit', $form['#submit']);
+        }
         $form['#submit'][$key] = 'tfa_login_submit';
         $form['#submit'][] = 'tfa_login_form_redirect';
       }
