public static function resendEmailFromLog($id) { $resendEmail = false; global $wpdb; $tableName = Cart66Common::getTableName('email_log'); $sql = "SELECT * from {$tableName} where id = {$id}"; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $r) { $resendEmail = Cart66Notifications::mail($r->to_email, $r->subject, $r->body, $r->headers); $email = new Cart66EmailLog(); $email_data = array('from_email' => $r->from_email, 'from_name' => $r->from_name, 'to_email' => $r->to_email, 'to_name' => $r->to_name, 'head' => array('headers' => $r->headers), 'subject' => $r->subject, 'msg' => $r->body, 'attachments' => $r->attachments, 'order_id' => $r->order_id); if (!$resendEmail) { if (Cart66Setting::getValue('log_resent_emails')) { $email->saveEmailLog($email_data, $r->email_type, $r->copy, 'RESEND FAILED'); } } else { if (Cart66Setting::getValue('log_resent_emails')) { $email->saveEmailLog($email_data, $r->email_type, $r->copy, 'RESEND SUCCESSFUL'); } } } } return $resendEmail; }
/** * Attempt to locate the account based on the passed in email address and reset that password * * StdClass Object is returned * $result->success = true/false * $result->message = The message to show the user * * @return object $result The result of the password reset attempt */ public function passwordReset() { $account = false; if (isset($_POST['login']['username'])) { $username = $_POST['login']['username']; $account = $this->getOne("where username = '******'"); } $result = new StdClass(); if ($account) { $newPwd = Cart66Common::randomString(); $account->password = md5($newPwd); $account->save(); $email = $account->email; $subject = Cart66Setting::getValue('reset_subject'); $message = Cart66Setting::getValue('reset_intro'); $message .= "\n\nYour new password is: {$newPwd}"; $headers = 'From: ' . Cart66Setting::getValue('reset_from_name') . ' <' . Cart66Setting::getValue('reset_from_address') . '>' . "\r\n\\"; Cart66Notifications::mail($email, $subject, $message, $headers); $result->success = true; $result->message = "A new password has been emailed to {$email}"; } else { $result->success = false; $result->message = "We couldn't find an account with that username."; } return $result; }