I am trying to make an email route based on whether a cookie is satisfied. However, it's harder than I thought. What trick am I missing? Here's what I have:
cookie is $_COOKIE["src"] and will have nothing if not triggered. To route the email I know that I need a selection enabled to use as conditional logic. I want to create this selection field and CSS it as display:none.
I have been able to get the right code except here the function does not know that the cookie is set:
if($_COOKIE["src"]){
$items[] = array("value" => "gsm", "text" => "gsm");
} else {
$items[] = array("value" => "", "text" => "");
}
this is the entire code:
function my_custom_population_function($form){
$items = array();
if($_COOKIE["src"]){
$items[] = array("value" => "gsm", "text" => "gsm");
} else {
$items[] = array("value" => "", "text" => "");
}
foreach($form["fields"] as &$field)
if($field["id"] == 8){
$field["choices"] = $items;
}
return $form;
}
also, i will want to share this amongst all forms but the input number will not always be 8. any way around duplicate code?