Skip to content

Instantly share code, notes, and snippets.

@alpha1
Created November 9, 2017 22:38
Show Gist options
  • Save alpha1/bd4c4393077de7a91768d19ed6e208f1 to your computer and use it in GitHub Desktop.
Save alpha1/bd4c4393077de7a91768d19ed6e208f1 to your computer and use it in GitHub Desktop.
Gravity Forms Show Entry Key and Value on Entry Detail Page
<?php
add_filter( 'gform_entry_field_value', 'display_key_and_value', 10, 4 );
function display_key_and_value( $value, $field, $entry, $form ){
switch( $field['type'] ){
case "checkbox":
break;
case "select":
case "radio":
$answers = wp_list_pluck( $field['choices'], 'value', 'text' );
if( in_array( $value, $answers ) ){
$value_name = array_search( $value, $answers);
if( $value != $value_name ){
return $value_name .' <i>( '. $value .' )</i>';
}
}
break;
default:
return $value;
break;
}
return $value;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment