Don't allow membership renewals when they aren't near expiration

master
Skylar Ittner 5 years ago
parent afb82c4072
commit 9d56af802d

@ -39,6 +39,13 @@ if (empty($IN_SITE)) {
case "bademail":
$msg = "That email address doesn't look right. Please try again.";
break;
case "tooearly":
if (!empty($_GET['exp']) && is_numeric($_GET['exp'])) {
$msg = "This membership isn't expiring until " . date("F Y", $_GET['exp'] * 1) . " and cannot be renewed yet.";
} else {
$msg = "This membership isn't close enough to expiration and cannot be renewed yet.";
}
break;
}
}
if ($msg != "") {

@ -19,6 +19,15 @@ if (!empty($_POST['email'])) {
die("We don't have that email on file for any current families.");
}
$familyid = $database->get('families', 'familyid', ['email' => strtolower($_POST['email'])]);
// Check expiration date
$expires = (new Family())->load($familyid)->getExpires();
if ($expires > strtotime("+6 months")) {
header("Location: ./?page=renew&msg=tooearly&exp=$expires");
die("This membership isn't expiring until " . date("F Y", $expires) . " and cannot be renewed yet.");
}
$code = mt_rand(100000, 999999);
$_SESSION['code'] = $code;
$_SESSION['maybefamily'] = $familyid;

Loading…
Cancel
Save