Drupal Modify Login System

2.7k Views Asked by At

I'm newbie in drupal... I have a drupal website, and i want to extend its login system - i've been looking around the code but end up with headache.

what i wan to do is:

  1. I want to put additional hidden form inside any login form
  2. create a session variable that will be used on login process (after user click submit) and then destroy the session after that.
  3. extend the login validation system inside drupal based on point 1 & 2 above - so i need to to control if my extended validation is valid (and drupal validation is valid) then go to where? otherwise then go to where?

so with that I'll have my own login system + drupal login system Is somebody ever try this before?

fyi: I'm using drupal 6

Thank you in Advance for helping me

And

2

There are 2 best solutions below

0
gapple On BEST ANSWER

To modify the login form, you will likely need hook_form_alter() and knowledge of the Form API

  • You can add additional elements to the login form, including hidden fields. Hidden can either mean hidden html form elements (<input type='hidden'/>) or values that are not output in the HTML at all but are stored server side for the corresponding validate and submit functions.
  • You can add additional functions to $form['#validate'] to change the login criteria (whether the login is accepted or not)
  • You can add additional functions to $form['#submit'] (note the '#') to add operations to perform after the user's login has passed validation. The default submit handler, user_login_submit(), simply redirects the user to their account page.
0
Sid Kshatriya On

You should also consider checking http://drupal.org/project/logintoboggan . Logintoboggan is a module that tweaks and changes Drupal's default login by adding a lot of features. You can see how they achieved certain functionalities by reading the code. That will help you when you write your own code.