0

I don't want the password field to be a required user registration field. How can I remove the password field? Is this done by changes in user.module file?

1

4 Answers 4

1

Just Enable "Require e-mail verification when a visitor creates an account." in "admin/config/people/accounts" page. That will remove password fields and provide you extra security also ..

enter image description here

6
  • how to remove password field from user login form? I want, user must be login by its username only. No password required. Commented Mar 20, 2014 at 9:50
  • An user account is protected by password always.. Without password User X can login to User Y account... Your above question doesn't makes sense.. I am afraid you cannot do that due to security implications and drupal doesn't allow that :-)
    – Anil Sagar
    Commented Mar 20, 2014 at 9:52
  • If i put a validation that a username will not be used twice, then may i achieve this??? Commented Mar 20, 2014 at 9:53
  • Username is always unique in Drupal... The problem you need to address is how you can authenticate into the system.. Usernames are displayed in the site in various pages.. For Example when user create content or comments his username is displayed.. Most importantly in drupal super username is admin.. So if you take only username while logging in .. i can input admin as username and gain access to Drupal Portal and do what ever i want..
    – Anil Sagar
    Commented Mar 20, 2014 at 9:55
  • one more question. I am using generate password module, by this i am able to register without password and in user.module, i made some changes and email id filed is also not required. after that as i register using only username and trying to login with only username, it showing password field is required. Commented Mar 20, 2014 at 10:06
1

You can use Generate Password module to achieve this goal. This module makes the password field optional (or hidden) on the add new user page (admin & registration). If the password field is not set during registration, the system will generate a password. You can optionally display this password at the time it's created.

For more info go through the documentation of this module.

0

You need to write form_alter

 function MODULE_form_alter($form, &$form_state, $form_id){
    if ($form_id == "user_register_form") {
          $form['account']['pass']['#access']  = FALSE;

    }       
    return $form;
 }

in your form_submit you can not save blank password in DB so while saving create one temporary password

        $password = user_password(8);

and pass it in user_save. You may also need to alter the validation hook.

Hope this will help you

0

To add to @CodeSurfer's answer, you can generate a password on the form_alter.

function MODULE_form_alter($form, &$form_state, $form_id){
     if ($form_id == "user_register_form") {
        $form['account']['pass']['#type'] = 'value';
        $form['account']['pass']['#value'] = sha1(user_password());
     }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.