Description
Use this action to inject markup to any non-first column of every entry in the entry list grid.
Usage
add_action( 'gform_entries_column', 'add_icon', 10, 5 );
Parameters
Parameter | Type | Description |
---|---|---|
$form_id | integer | ID of the current form. |
$field_id | integer | ID of the field that this column applies to. |
$value | string | Current value that will be displayed in this cell. |
$entry | Entry Object | Current entry object. |
$query_string | string | Current page query string with search and pagination state. |
Examples
Append an icon to the column depending on the text being displayed in the cell.
Note: This example assumes that field with ID 5 is NOT placed in the first column on the entry grid. This hook does not fire for the first column in the grid. Look at gform_entries_first_column to add content to the first column.
add_action( 'gform_entries_column', 'add_icon', 10, 5 );
function add_icon( $form_id, $field_id, $value, $entry, $query_string ) {
// Targeting form 190 only.
if ( $form_id != 190 ) {
return;
}
// Targeting field 5 only.
if ( $field_id != 5 ) {
return;
}
if ( $value == 'yes' ) {
echo " <img src='" . GFCommon::get_base_url() . "/images/tick.png' />";
} elseif ( $value == 'no' ) {
echo " <img src='" . GFCommon::get_base_url() . "/images/stop.png' />";
}
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This action hook is located in GFEntryList::leads_page() in entry_list.php.