reset_password

Handles resetting the user's password.

Description

reset_password( (object) $user, (string) $new_pass ); 

Parameters (2)

0. $user (object)
The user.
1. $new_pass (string)
New password for the user in plaintext

Usage

  1. if ( !function_exists( 'reset_password' ) ) { 
  2. require_once ABSPATH . WPINC . '/user.php'; 
  3.  
  4. // The user. 
  5. $user = null; 
  6.  
  7. // New password for the user in plaintext 
  8. $new_pass = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = reset_password($user, $new_pass); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/user.php  
  1. function reset_password( $user, $new_pass ) { 
  2. /** 
  3. * Fires before the user's password is reset. 
  4. * @since 1.5.0 
  5. * @param object $user The user. 
  6. * @param string $new_pass New user password. 
  7. */ 
  8. do_action( 'password_reset', $user, $new_pass ); 
  9.  
  10. wp_set_password( $new_pass, $user->ID ); 
  11. update_user_option( $user->ID, 'default_password_nag', false, true ); 
  12.  
  13. /** 
  14. * Fires after the user's password is reset. 
  15. * @since 4.4.0 
  16. * @param object $user The user. 
  17. * @param string $new_pass New user password. 
  18. */ 
  19. do_action( 'after_password_reset', $user, $new_pass );