Advertisement
Guest User

pass

a guest
May 28th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. function check_password_reset_key($key, $login) {
  2. global $wpdb;
  3.  
  4. $key = preg_replace('/[^a-z0-9]/i', '', $key);
  5.  
  6. if ( empty( $key ) || !is_string( $key ) )
  7. return new WP_Error('invalid_key', __('Invalid key'));
  8.  
  9. if ( empty($login) || !is_string($login) )
  10. return new WP_Error('invalid_key', __('Invalid key'));
  11.  
  12. $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
  13.  
  14. if ( empty( $user ) )
  15. return new WP_Error('invalid_key', __('Invalid key'));
  16.  
  17. return $user;
  18. }
  19.  
  20. /**
  21. * Handles resetting the user's password.
  22. *
  23. * @param object $user The user
  24. * @param string $new_pass New password for the user in plaintext
  25. */
  26. function reset_password($user, $new_pass) {
  27. /* do_action('password_reset', $user, $new_pass); */
  28.  
  29. /*
  30. global $wpdb;
  31.  
  32. " update $wpdb->users
  33. set user_pass = " . $new_pass .
  34. " where user_login = " . $user; */
  35.  
  36. wp_set_password($new_pass, $user->ID);
  37.  
  38. wp_password_change_notification($user);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement