Forked from RickeyMessick/Gravity Forms get all fields function
Created
November 19, 2019 13:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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