we have multiple forms on our website, on most of them people will have to enter name, phone and email. to make this more userfriendly, here's a snippet on how to store these values in cookies and prepopulate the forms with it.
to make this work you'll have to check 'allow field to be populated dynamically' and set the parameter name accordingly (in this example 'name', 'phone' and 'email')
here's the script, that should go in your functions.php
add_action("gform_pre_submission", "pre_submission_handler");
function pre_submission_handler($form_meta) {
$saveVars = array("name", "email", "phone");
foreach($form_meta["fields"] as $field) {
if (in_array($field["inputName"], $saveVars)) {
setcookie("gf_".$field["inputName"], $_POST["input_" . $field["id"]], time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);
}
}
}
add_filter("gform_field_value_name", "populate_name");
function populate_name() {
return $_COOKIE["gf_name"];
}
add_filter("gform_field_value_phone", "populate_phone");
function populate_phone() {
return $_COOKIE["gf_phone"];
}
add_filter("gform_field_value_email", "populate_email");
function populate_email() {
return $_COOKIE["gf_email"];
}
hope this helps someone...