Title: password-reset from admin
Last modified: August 19, 2016

---

# password-reset from admin

 *  [Franz Josef Kaiser](https://wordpress.org/support/users/f-j-kaiser/)
 * (@f-j-kaiser)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/password-reset-from-admin/)
 * Hi!
 * I´m using WP as a CMS for an event and i´m now trying to make a list of all users
   in which i add a button at the end of each row, where i can reset (and re-send)
   the user-password. If i can´t get around this, i would have to reset every user
   with entering his/here e-mail adress into the lostpassword-form on wp-login.php.
 * I looked through the function in wp-login.php but i can´t get around this. Could
   someone push me a little further and explain me how i would trigger those functions?
   Here goes the code from wp-login.php incl. line-nr.
 *     ```
       216  /**
        217   * Handles resetting the user's password.
        218   *
        219   * @uses $wpdb WordPress Database object
        220   *
        221   * @param string $key Hash to validate sending user's password
        222   * @return bool|WP_Error
        223   */
        224  function reset_password($key, $login) {
        225      global $wpdb;
        226
        227      $key = preg_replace('/[^a-z0-9]/i', '', $key);
        228
        229      if ( empty( $key ) || !is_string( $key ) )
        230          return new WP_Error('invalid_key', __('Invalid key'));
        231
        232      if ( empty($login) || !is_string($login) )
        233          return new WP_Error('invalid_key', __('Invalid key'));
        234
        235      $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
        236      if ( empty( $user ) )
        237          return new WP_Error('invalid_key', __('Invalid key'));
        238
        239      // Generate something random for a password...
        240      $new_pass = wp_generate_password();
        241
        242      do_action('password_reset', $user, $new_pass);
        243
        244      wp_set_password($new_pass, $user->ID);
        245      update_user_option($user->ID, 'default_password_nag', true, true); //Set up the Password change nag.
        246      $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
        247      $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
        248      $message .= site_url('wp-login.php', 'login') . "\r\n";
        249
        250      if ( is_multisite() )
        251          $blogname = $GLOBALS['current_site']->site_name;
        252      else
        253          // The blogname option is escaped with esc_html on the way into the database in sanitize_option
        254          // we want to reverse this for the plain text arena of emails.
        255          $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
        256
        257      $title = sprintf( __('[%s] Your new password'), $blogname );
        258
        259      $title = apply_filters('password_reset_title', $title);
        260      $message = apply_filters('password_reset_message', $message, $new_pass);
        261
        262      if ( $message && !wp_mail($user->user_email, $title, $message) )
        263            wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') );
        264
        265      wp_password_change_notification($user);
        266
        267      return true;
        268  }
       ```
   
 * Thanks A LOT!

The topic ‘password-reset from admin’ is closed to new replies.

## Tags

 * [password](https://wordpress.org/support/topic-tag/password/)
 * [resend](https://wordpress.org/support/topic-tag/resend/)
 * [reset](https://wordpress.org/support/topic-tag/reset/)
 * [user](https://wordpress.org/support/topic-tag/user/)

 * 0 replies
 * 1 participant
 * Last reply from: [Franz Josef Kaiser](https://wordpress.org/support/users/f-j-kaiser/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/password-reset-from-admin/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
