| | 2000 | |
| | 2001 | /** |
| | 2002 | * Get the URL for the reset password screen. |
| | 2003 | * |
| | 2004 | * @param int $user_id |
| | 2005 | * @return string URL |
| | 2006 | */ |
| | 2007 | function get_user_reset_password_url( $user_id ) { |
| | 2008 | global $wpdb; |
| | 2009 | |
| | 2010 | $user = get_userdata( $user_id ); |
| | 2011 | |
| | 2012 | // Generate something random for a password reset key. |
| | 2013 | $key = wp_generate_password( 20, false ); |
| | 2014 | |
| | 2015 | /** |
| | 2016 | * Fires when a password reset key is generated. |
| | 2017 | * |
| | 2018 | * @since 2.5.0 |
| | 2019 | * |
| | 2020 | * @param string $user_login The username for the user. |
| | 2021 | * @param string $key The generated password reset key. |
| | 2022 | */ |
| | 2023 | do_action( 'retrieve_password_key', $user->user_login, $key ); |
| | 2024 | |
| | 2025 | // Now insert the key, hashed, into the DB. |
| | 2026 | if ( empty( $wp_hasher ) ) { |
| | 2027 | require_once ABSPATH . 'wp-includes/class-phpass.php'; |
| | 2028 | $wp_hasher = new PasswordHash( 8, true ); |
| | 2029 | } |
| | 2030 | $hashed = $wp_hasher->HashPassword( $key ); |
| | 2031 | $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) ); |
| | 2032 | |
| | 2033 | return network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login'); |
| | 2034 | } |
| | 2035 | No newline at end of file |