1

I’m trying to set a minimum length for the new password when resetting the password. I would like to add something like this just functional.

add_action( 'password_reset', 'reset_my_password', 10, 2 );
function reset_my_password($user, $new_pass, $errors) {
$errors = new WP_Error();
if ( strlen( $_POST['new_pass'] ) < 8 ) {
$errors->add( 'password_too_short', "<strong>ERROR</strong>: Password is too short." );
}
}

Any help with this would appreciated.

1

You may want to use the validate_password_reset hook instead.

Try

add_action( 'validate_password_reset' , 'se_password_min_length_check' 10, 2 );

function se_password_min_length_check( $errors, $user){
    if(strlen($_POST['pass1']) < 8)
        $errors->add( 'password_too_short', 'ERROR: password is too short.' );
}
  • Thank you after I added $priority and $accepted_args this worked for me. – Mio May 8 '15 at 20:37

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.