Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawndones/e6a9f73fc15c334eba0d0422ef297e13 to your computer and use it in GitHub Desktop.
Save shawndones/e6a9f73fc15c334eba0d0422ef297e13 to your computer and use it in GitHub Desktop.
Gravity Forms get all fields function to use with gform_after_submission to display just filled out fields
function get_all_fields($entry, $form)
{
//only do this for a certain form (id 53 for example)
// if ($form["id"] == 17)
//{
foreach($form["fields"] as &$field)
{
//see if this is a multi-field, like name or address
if (is_array($field["inputs"]))
{
//loop through inputs
foreach($field["inputs"] as &$input)
{
$label = $input["label"];
//get value from entry object; change the id to a string
$value = $entry[strval($input["id"])];
if (!empty($value)) {
$output .= $label . ':' . $value . ' ';
}
//print_r($output);
}
}
else
{
$label = $field["label"];
//get value from entry object
$value = $entry[$field["id"]];
if (!empty($value)) {
$output .= $label . ':' . $value . ' ';
}
//print_r($output);
}
}
//print_r($output);
return $output;
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment