Created
November 9, 2017 22:38
-
-
Save alpha1/bd4c4393077de7a91768d19ed6e208f1 to your computer and use it in GitHub Desktop.
Gravity Forms Show Entry Key and Value on Entry Detail Page
This file contains hidden or 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
<?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