Guest User

Untitled

a guest
Jan 22nd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. if(isset($_POST['user_login']) && !empty($_POST['user_login'])):
  2. $incorrect_login = FALSE;
  3. require_once(ABSPATH . WPINC . '/registration.php');
  4. // Grab User Data
  5. if(strpos($_POST['user_login'], '@')):
  6. $user_data = get_user_by('email', trim($_POST['user_login']));
  7. else:
  8. $user_data = get_user_by('login', trim($_POST['user_login']));
  9. endif;
  10.  
  11. // If the Username or Email Match
  12. if($user_data):
  13. // Set Vars
  14. $user_login = $user_data->user_login;
  15. $user_email = $user_data->user_email;
  16.  
  17. // Set a New Password Reset Key
  18. $key = wp_generate_password(20, false);
  19. $var = wp_update_user(array('ID' => $user_data->ID, 'user_activation_key' => $key));
  20. $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
  21.  
  22. // If No Username or Email Match - Return Error
  23. else:
  24. $incorrect_login = TRUE;
  25. endif;
  26. else:
  27. $incorrect_login = TRUE;
  28. endif;
Add Comment
Please, Sign In to add comment