Redirect rules
I've created a page both the login form and the registration form submit to called "logincheck.php". I used the redirect server behavior to redirect based on the SA rules I've defined.
Basically if a visitor is coming from the checkout page (login.php?checkout=1), I want them to be redirected back to checkout page after either login or registration.
If a visitor is NOT coming from checkout page (login.php) I want to re-direct to the my-account.php page.
It works for the registration form, but not the login. Also, I have the login and registration on the same page. Not sure what's wrong.
Here's the redirect code:
<?php
if(WA_Auth_RulePasses("checkout rule")){
$WA_Redirect_URL = "checkout/checkout.php";
$WA_Redirect_KeepQS = true;
if ($WA_Redirect_URL != "") {
if ($WA_Redirect_KeepQS && $WA_Redirect_URL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "") {
$WA_Redirect_URL .= ((strpos($WA_Redirect_URL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_Redirect_URL);
}
}
?>
<?php
if(!WA_Auth_RulePasses("checkout rule")){
$WA_Redirect_URL = "my-account.php";
$WA_Redirect_KeepQS = true;
if ($WA_Redirect_URL != "") {
if ($WA_Redirect_KeepQS && $WA_Redirect_URL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "") {
$WA_Redirect_URL .= ((strpos($WA_Redirect_URL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_Redirect_URL);
}
}?>