WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When a user resets their password via the link in the password reset email, I know I can use the password_reset hook to get the user object and the new password. I want to validate the new password to ensure that the strength requirements are met, but I'm not sure on how to generate the error messages so that they display above the form.

When I did this on the profile page via the user_profile_update_errors hook, I had a WP_Error I could add to, but not with this hook.

What would be the best way to handle this?

share|improve this question

You can try using hook the validate_password_reset to validate password.
Following code can be used to validate alphanumeric password.

    function wdm_validate_password_reset( $errors, $user)
        $exp = '/^(?=.*\d)((?=.*[a-z])|(?=.*[A-Z])).{6,32}$/';

        if(strlen($_POST['pass1'])<6 || !preg_match($exp, $_POST['pass1']) )
               $errors->add( 'error',  'Password must be alphanumeric and contain minimum 6 characters.','');
share|improve this answer

I'm not 100% sure If I understood your question, but here's the plugin that forces user to input strong password.

share|improve this answer
The plugin you mentioned only enforces this on the profile page, not the password reset page. – NightHawk Sep 17 '12 at 15:42
Have you checked the plugin file on github ? github.com/gyrus/Force-Strong-Passwords/blob/master/… read from line 120 – Kuldeep Daftary Sep 17 '12 at 15:54
The thing is, I found a way to enforce the requirements server-side, I just don't know enough about WordPress and how to use WP_Error to display corresponding errors on the page. – NightHawk Sep 17 '12 at 16:17
Can you share the code you have written so far? – Kuldeep Daftary Sep 17 '12 at 18:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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