Guest User

Untitled

a guest
Apr 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. if (!$user_ID){
  2. if(isset($_POST['op_classiera']) ){
  3. if($_POST['submit'] == 'Reset'){
  4.  
  5. // First, make sure the email address is set
  6. if ( isset( $_POST['email'] ) && ! empty( $_POST['email'] ) ) {
  7.  
  8. // Next, sanitize the data
  9. $email_addr = trim( strip_tags( stripslashes( $_POST['email'] ) ) );
  10.  
  11. $user = get_user_by( 'email', $email_addr );
  12. $user_ID = $user->ID;
  13.  
  14. if( !empty($user_ID)) {
  15.  
  16. $new_password = wp_generate_password( 12, false );
  17.  
  18. if ( isset($new_password) ) {
  19.  
  20. wp_set_password( $new_password, $user_ID );
  21.  
  22. $message = "Check your email for new password.";
  23.  
  24. $from = get_option('admin_email');
  25. $headers = 'From: '.$from . "rn";
  26. $subject = "Password reset!";
  27. $msg = "Reset password.nYour login detailsnNew Password: $new_password";
  28. wp_mail( $email_addr, $subject, $msg, $headers );
  29.  
  30. $resetSuccess = 1;
  31.  
  32. }
  33.  
  34. } else {
  35.  
  36. $message = "There is no user available for this email.";
  37.  
  38. } // end if/else
  39.  
  40. } else {
  41. $message = "Email should not be empty.";
  42. }
  43.  
  44. }
Add Comment
Please, Sign In to add comment