处理重置用户密码的句柄。

原型

reset_password( WP_User $user, string $new_pass )

参数

$user (WP_User) (Required) 用户

$new_pass (string) (Required) 明文用户的新密码

源文件

路径:wp-includes/user.php

<?php
...
function reset_password( $user, $new_pass ) {
	/**
	 * Fires before the user's password is reset.
	 *
	 * @since 1.5.0
	 *
	 * @param object $user     The user.
	 * @param string $new_pass New user password.
	 */
	do_action( 'password_reset', $user, $new_pass );
	wp_set_password( $new_pass, $user->ID );
	update_user_option( $user->ID, 'default_password_nag', false, true );
	/**
	 * Fires after the user's password is reset.
	 *
	 * @since 4.4.0
	 *
	 * @param WP_User $user     The user.
	 * @param string  $new_pass New user password.
	 */
	do_action( 'after_password_reset', $user, $new_pass );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/reset_password/