1

I'm using the Wordpress's built-in forgot password reset form and views.

I want to limit the number of reset password email attempts. By default Wordpress allows you to send unlimited reset password emails and I want to set a limit. How can I do?

This feature is only available in the Wordfence security plugin. I don't want to use Wordfence. I searched for other plugins but could not find them. I can actually write code. You can write a suggestion.

1 Answer 1

0

You need put the attempts on user meta, then do check every time user hit reset passwords.

add_action( 'password_reset', 'my_password_reset', 10, 2 );
function my_password_reset( $user, $new_pass ) {
    $limit=5;// Set the limit here
    $attempts=(int) get_user_meta($user->ID,"reset_attempts",true);
    if($attempts>$limit){
       //Do something in here, example redirect to warning page.
       wp_redirect( "/warning" );
       exit;
    } 
    update_user_meta($user->ID,"reset_attempts",$attempts++);
}
2
  • Tested and it did not work as expected, any updates please?
    – Matthew
    May 15 at 9:11
  • @Matthew: this comment is not very useful, because it's unknown what your expectations are.. If you need more info you could ask a new question, like this one: stackoverflow.com/questions/72246946/… , or here on wordpress.stackexchange.com)
    – Luuk
    May 15 at 9:20

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.