Title: problem with reset password plugin
Last modified: February 25, 2021

---

# problem with reset password plugin

 *  Resolved [luckysistemi](https://wordpress.org/support/users/luckysistemi/)
 * (@luckysistemi)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/problem-with-reset-password-plugin/)
 * Since WP 5.4.0 ‘lostpassword_post’ is fired with two parameters ($errors and 
   $userdata)
    You can avoid to guess userdata from $_POST[‘user_login’]
 * In fact I had a problem with a plugin that uses a different name for the field.
 * I propose you a change in file: new-user-approve/new-user-approve.php
 * `add_action( 'lostpassword_post', array( $this, 'lost_password' ),10,2 )`
 * and
 *     ```
       public function lost_password( $errors, $user_data )
       {
       /*
           $is_email = strpos( $_POST['user_login'], '@' );
   
           if ( $is_email === false ) {
               $username = sanitize_user( $_POST['user_login'] );
               $user_data = get_user_by( 'login', trim( $username ) );
           } else {
               $email = is_email( $_POST['user_login'] );
               $user_data = get_user_by( 'email', $email );
           }
       */
           if ( $user_data->pw_user_status && $user_data->pw_user_status != 'approved' ) {
               $errors->add( 'unapproved_user', __( '<strong>ERROR</strong>: User has not been approved.', 'new-user-approve' ) );
           }
           return $errors;
       }
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [wpexpertssupportteam](https://wordpress.org/support/users/wpexpertssupportteam/)
 * (@wpexpertssupportteam)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/problem-with-reset-password-plugin/#post-14105449)
 * Hi [@luckysistemi](https://wordpress.org/support/users/luckysistemi/),
 * Thank you for helping us improve the plugin. We have forwarded the details to
   our technical team. If the proposed changes are approved, then we will release
   them in one of our upcoming updates.
 *  Thread Starter [luckysistemi](https://wordpress.org/support/users/luckysistemi/)
 * (@luckysistemi)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/problem-with-reset-password-plugin/#post-14172954)
 * Hi,
    there is a safer way to manage this topic. In fact usin lostpassword_post
   action is too late.
 * you can use the filter
    `add_filter( 'allow_password_reset', array(&$this, 'lk_allow_pw_reset'),
   10, 2 );` and replace the method lost_password with
 *     ```
           function lk_allow_pw_reset( $result, $user_id ) {   
               $user_data = get_user_by( 'id', $user_id );        
               if ( $user_data->pw_user_status && $user_data->pw_user_status != 'approved' ) {
                   $result = new WP_Error( 'unapproved_user', __( '<strong>ERROR</strong>: User has not been approved.', 'new-user-approve' ) );
               }
               return $result;
           }
       ```
   
    -  This reply was modified 5 years, 1 month ago by [luckysistemi](https://wordpress.org/support/users/luckysistemi/).
 *  [wpexpertssupportteam](https://wordpress.org/support/users/wpexpertssupportteam/)
 * (@wpexpertssupportteam)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/problem-with-reset-password-plugin/#post-14184911)
 * Hi [@luckysistemi](https://wordpress.org/support/users/luckysistemi/),
 * we have forwarded this to our technical team they will review it before adding
   this as a part of this plugin.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘problem with reset password plugin’ is closed to new replies.

 * ![](https://ps.w.org/new-user-approve/assets/icon-128x128.gif?rev=2544141)
 * [New User Approve](https://wordpress.org/plugins/new-user-approve/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/new-user-approve/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/new-user-approve/)
 * [Active Topics](https://wordpress.org/support/plugin/new-user-approve/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/new-user-approve/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/new-user-approve/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [wpexpertssupportteam](https://wordpress.org/support/users/wpexpertssupportteam/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/problem-with-reset-password-plugin/#post-14184911)
 * Status: resolved