Need help on a callback function with login form
function da_form_alter (&amp;$form, $form_state, $form_id) {
   if ($form_id == 'user_login' || $form_id == 'user_login_block' ) {
     if (isset($form_state['post']['name'])) {
       $form['#validate'][] = da_login_validate($form, $form_state);
    }
  }
}

function da_login_validate($form, $form_state) {
  // Here you should check wheather the user is valid or not..
}


Better way to do this: you should read the source code of any module. For example, read the code of Facebook Connect which does the same thing.