Adding Logic to Redirects
By Paul
4/5 based on 1 vote. The median rating is 4.
By Paul
Sometimes, some of you may want to have a form redirect differently depending on the values the user has selected in it. You can apply a special message and destination url when a particular form field has a particular value, by adding the logic to your tweaks file like this:
Suppose you have a custom field in your 'submit article' form called 'iwantpageb'. When it has the value 'yes' you want to send people to b.html with a "thank you for choosing page b" redirect page message in the meantime. This is what you'd use:
If you want to test for something other than equality, you can specify another operator in an optional 6th term. This can be any standard PHP operator: >, >=, <, <=, !=. For example, to redirect when something is greater than 5:
$redirectchecks[0] = array("profile.php?action=editprofile", "fieldname", "fieldvalue", "redirect message to display", "destination url");
$redirectchecks[1] = array("profile.php?action=editprofile", "anotherfieldname", "anotherfieldvalue", "another redirect message to display", "anotherdestination url");
$redirectchecks[2] = array("suggest.php?action=addlink", "fieldname", "fieldvalue", "redirect message to display", "destination url");
Suppose you have a custom field in your 'submit article' form called 'iwantpageb'. When it has the value 'yes' you want to send people to b.html with a "thank you for choosing page b" redirect page message in the meantime. This is what you'd use:
$redirectchecks[0] = array("suggest.php?action=addlink", "iwantpageb", "yes", "thank you for choosing page b", "b.html");
If you want to test for something other than equality, you can specify another operator in an optional 6th term. This can be any standard PHP operator: >, >=, <, <=, !=. For example, to redirect when something is greater than 5:
$redirectchecks[0] = array("suggest.php?action=addlink", "something", "5", "thank you for choosing page b", "b.html", ">");
Rating:
4/5 based on 1 vote. The median rating is 4.
Submitted: 04/02/08 (Edited 04/13/08)
Description: How to make form submissions redirect with a special message and destination when a particular form field has a particular value.
Views:
249 views. Averaging 1 per day.
In the most recent 30 day period, there've been 28 views.

Print
E-Mail