Skip to content

Instantly share code, notes, and snippets.

@spivurno
Created June 30, 2014 18:25
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 spivurno/4fab899db8b342f67378 to your computer and use it in GitHub Desktop.
Save spivurno/4fab899db8b342f67378 to your computer and use it in GitHub Desktop.
Get the selected survey choice based on entry value.
/**
* Get the selected survey choice based on entry value.
*/
function gw_survey_get_selected_choice( $entry, $field_id ) {
$form = GFAPI::get_form( $entry['form_id'] );
$key = rgar( $entry, $field_id );
foreach( $form['fields'] as $field ) {
if( $field['id'] != $field_id )
continue;
foreach( $field['choices'] as $choice ) {
if( $choice['value'] == $key )
return $choice;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment