The gform_entries_field_value filter allows you to change a field’s value before it gets displayed on the Entry list page. This is helpful when creating custom field types that require special formatting for the entry list.
Usage
add_filter('gform_entries_field_value', 'modify_entry_values');
Parameters
- $value (string): The current entry value to be filtered.
- $form_id (integer): The ID of the form from which the entry value was submitted.
- $field_id (integer): The ID of the field from which the entry value was submitted.
- $entry (Entry Object): The current entry.
More information
See Gravity Forms Docs: gform_entries_field_value
Examples
Display category names
This example assumes the original value is a comma delimited list of category IDs (i.e. ‘1,3,4’). We then break the IDs into an array, loop through each ID to get the category name, and format the category name into an unordered list.
add_filter('gform_entries_field_value', 'display_category_names', 10, 3); function display_category_names($value, $form_id, $field_id) { if ($form_id != 3 || $field_id != 4) { return $value; } $new_value = ''; $categories = explode(',', $value); foreach($categories as $category) { $new_value .= '<li>' . get_cat_name($category) . '</li>'; } return '<ul>' . $new_value . '</ul>'; }
Display choice label
This example displays the choice label instead of value for choice based fields.
add_filter('gform_entries_field_value', function($value, $form_id, $field_id, $entry) { $field = GFAPI::get_field($form_id, $field_id); $value_fields = array('checkbox', 'radio', 'select'); if (is_numeric($field_id) && in_array($field->get_input_type(), $value_fields)) { $value = $field->get_value_entry_detail(RGFormsModel::get_lead_field_value($entry, $field), '', true, 'text'); } return $value; }, 10, 4);
File Upload Field
This example shows how you can define the markup returned for the file upload type field.
add_filter('gform_entries_field_value', 'file_upload_field_values', 10, 4); function file_upload_field_values($value, $form_id, $field_id, $entry) { $field = GFAPI::get_field($form_id, $field_id); if (is_object($field) && $field->get_input_type() == 'fileupload') { // ...custom code here... } return $value; }
Link to user profile
This example shows how you can link the value of the entry created_by property to the user profile page.
add_filter('gform_entries_field_value', function($value, $form_id, $field_id, $entry) { if ($field_id === 'created_by' && !empty($value)) { $value = sprintf('<a href="%s">%s</a>', esc_url(get_edit_user_link($entry['created_by'])), esc_html($value)); } return $value; }, 10, 4);