I'm looking for the easiest possible way to modify or alter the password policy constraints error text. The following is the default the users see.

The password does not include enough variation to be secure.
• Password must contain characters of at least 3 different types
(lowercase, uppercase, digit or punctuation).
• Password must contain at least one digit.
• Password must be at least 8 characters in length.
• Password must contain at least one lowercase character.
• Password must contain at least one punctuation (not whitespace or an alphanumeric) character.
• Password must contain at least one uppercase character.

I would like to modify this text to display to users like so:

Password must:
• Be at least 8 characters
• Have at least one lowercase letter
• Have at least one number
• etc etc.

Would this be possible using a form alter or other methods?


Short answer:

Of course there is a module for that.

Actually, more than one:

https://www.cmsdrupal.com/blog/how-implement-custom-password-policy-drupal https://dev.acquia.com/blog/password-policies-and-drupal/03/04/2017/17856

Longer answer:

Since you don't just want to change the policy (you want to change the form markup too) you might also need to use hook_form_user_login_block_alter(&$form, &$form_state, $form_id).

  • I am currently using the password policy module and have a password policy in place. Yes I do want to modify the markup. I will try the hook_form_user_login_block_alter(&$form, &$form_state, $form_id). Thanks
    – Brian N
    Dec 7 '18 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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