To Add an Extra Login Field Open modules…

Posted by

To Add an Extra Login Field:

  1. Open modules/user/user.module


  1. Find the following function:
    1. function user_login () {


  1. Add the following before the line that starts with ‘$form[‘submit’]:
    1. //mod
    2. $form[‘otp’] = array(‘#type’ => ‘password’,
    3. ‘#title’ => t(‘mKey’),
    4. ‘#maxlength’ => 60,
    5. ‘#size’ => 15,
    6. ‘#required’ => TRUE,
    7. );
    8. //end mod


  1. Find the following function:
    1. function user_login_block() {


  1. Add the following before the line that starts with ‘$form[‘submit’]:
    1. //mod
    2. $form[‘otp’] = array(‘#type’ => ‘password’,
    3. ‘#title’ => t(‘mKey’),
    4. ‘#maxlength’ => 60,
    5. ‘#size’ => 15,
    6. ‘#required’ => TRUE,
    7. );
    8. //end mod


  1. Find the following function:
    1. function user_authenticate($form_values = array()) {


  1. Add the following before the line that starts with ‘//Name and pass keys are required’
    1. $otp =  $form_values[‘otp’];
    2. echo “otp is ” . $otp;
    3. break;


  1. Try to login. If the page goes blank and outputs the OTP you just insert, then you may proceed to replace step 7 with your custom authentication for this field.