Using Drupal 5.1. Is there a hook, or some other way I can grab control when the user login form is submitted?

There's a 'login' operation to hook_user(), but that gets called after the user has been logged in. I want to do a couple of checks on the username before the user login gets even that far.

I also found hook_form_alter() which allows me to change the login form before it's presented, but that's not quite what I want either.

I guess what I really want is to hang onto the user form validation code. Is there a way of getting in there? I've currently got a hack in the core I'd like to do without!

Comments

thrice’s picture

I found the answer. For the record, put the check in the 'load' operation of the hook_user(). It gets called every time the user is loaded from the database, which is something of an overkill for the one pre-login check I need to do, but it does the job.

mooffie’s picture

I guess what I really want is to hang onto the user form validation code. Is there a way of getting in there?

Yes, and it's easy: you add to the $form['#validate'] array:

http://groups.drupal.org/node/2284

(search page for "We now add a validation callback".)