[development] redirect login block when user enters wrong user/pass

John Barreiros johnbarreiros2 at gmail.com
Tue Oct 30 15:45:21 UTC 2007


Hi

First, I realize what I'm doing isn't the most usable, but it's how the
client wants it.

On the homepage, the user login block is styled all fancy and compact.
Unfortunately, it's compactness prevents a place for an error message if the
user messes up their username or password.

So, what I'd like to do, when the form fails validation, is redirect the
user to "/user" which displays the regular login form along with the error
messages that would of displayed within the block.
I tried the following (in my own module),

function myutility_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'user_login_block':
      $form['#validate'] = array('utility_user_login_validate' =>
array($form_id, $form));
      unset($form['links']);
      break;
  }
}

function myutility_user_login_validate($form_id, $form_values) {
  user_login_validate($form_id, $form_values);
  if (count(form_get_errors()) > 0) {
    drupal_set_message('test error message');
    //print "here";
    drupal_goto('user');
  }
}

The drupal_goto doesn't seem to work here. I'm fairly confident the code is
making it to the drupal_goto because if I uncomment the "print" statement is
does get called and prints out "here".

Any ideas why drupal_goto isn't working in this case?

Thanks for the help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20071030/3c35e09b/attachment.htm 


More information about the development mailing list