Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function check_password_reset_key($key, $login) {
- global $wpdb;
- $key = preg_replace('/[^a-z0-9]/i', '', $key);
- if ( empty( $key ) || !is_string( $key ) )
- return new WP_Error('invalid_key', __('Invalid key'));
- if ( empty($login) || !is_string($login) )
- return new WP_Error('invalid_key', __('Invalid key'));
- $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
- if ( empty( $user ) )
- return new WP_Error('invalid_key', __('Invalid key'));
- return $user;
- }
- /**
- * Handles resetting the user's password.
- *
- * @param object $user The user
- * @param string $new_pass New password for the user in plaintext
- */
- function reset_password($user, $new_pass) {
- /* do_action('password_reset', $user, $new_pass); */
- /*
- global $wpdb;
- " update $wpdb->users
- set user_pass = " . $new_pass .
- " where user_login = " . $user; */
- wp_set_password($new_pass, $user->ID);
- wp_password_change_notification($user);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement