gform_filter_links_entry_list

Description

The “gform_filter_links_entry_list” filter in Gravity Forms allows the list of filters at the top of the Entry List page to be modified.

Usage

add_filter( 'gform_filter_links_entry_list', 'your_function_name', 10, 3 );

Parameters

  • $filter_links array

    An array of each filter link. Sample array:

        array (
          0 => 
          array (
            'id' => 'all',
            'field_filters' => 
                array (
                ),
            'count' => '',
            'label' => 'All',
          ),
          1 => 
          array (
            'id' => 'unread',
            'field_filters' => 
                array (
                    0 => 
                    array (
                      'key' => 'is_read',
                      'value' => false,
                    ),
                ),
            'count' => '',
            'label' => 'Unread',
          ),
          2 => 
          array (
            'id' => 'star',
            'field_filters' => 
                array (
                    0 => 
                    array (
                      'key' => 'is_starred',
                      'value' => true,
                    ),
                ),
            'count' => '',
            'label' => 'Starred',
          ),
          3 => 
          array (
            'id' => 'spam',
            'field_filters' => 
                array (
                ),
            'count' => '',
            'label' => 'Spam',
          ),
          4 => 
          array (
            'id' => 'trash',
            'field_filters' => 
                array (
                ),
            'count' => '',
            'label' => 'Trash',
          ),
        )
    

  • $form Form Object

    The current form.

  • $include_counts bool

Examples

Basic usage.

This example will simply add the ‘My Custom Link’ to the Entries list page. It will not filter anything because it has a blank array for ‘field_filters’. So you would need to provide your own filter to make it work.

add_filter( 'gform_filter_links_entry_list', 'change_links', 10, 3 );
function change_links( $filter_links, $form, $include_counts ){
	$filter_links[] = array(
		'id' => 'mycustom',
		'field_filters' => array(), // You need to provide a filter array here to make this link do something.
		'label'   => 'My Custom Link',
	);
	return $filter_links;
}

Filter entries by field value.

The following example will add a new ‘Value test for Field id 1’ link that will reduce the entries list to only entries where field ID 1 has test as value.

// Filter Entries List to show only entries with value 'test' for field id 1.
add_filter( 'gform_filter_links_entry_list', 'filter_list_by_field_value', 10, 3 );
function filter_list_by_field_value( $filter_links, $form, $include_counts ){
	$filter_links[] = array(
		'id' => 'filterbyfield',
		'field_filters' => 
		array (
			0 => 
			array (
				'key' => 1, // ID of the field to check.
				'value' => 'test', // Only entries with this value for the above field id.
			),
		),
		'label'   => 'Value test for Field id 1',
	);
	return $filter_links;
}

Add a filter for “Not Starred” entries.

The following example will add a new ‘Not Starred’ link that will filter the entries list to show only entries where the is_starred property is set to false (entries with the gray star icon).

add_filter( 'gform_filter_links_entry_list', 'add_not_starred_filter', 10, 3 );
function add_not_starred_filter( $filter_links, $form, $include_counts ) {

	$summary = $include_counts ? GFFormsModel::get_form_counts( $form['id'] ) : array();

	$active_entry_count = absint( rgar( $summary, 'total' ) );
	$starred_count     = absint( rgar( $summary, 'starred' ) );

	$filter_links[] = array(
		'id' => 'no-star',
		'field_filters' => array(
			array( 'key' => 'is_starred', 'value' => false ),
				),
				'count' => $active_entry_count - $starred_count,
				'label'   => esc_html_x( 'Not Starred', 'Entry List', 'gravityforms' ),
			);

	return $filter_links;
}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in Gravity Forms version 1.9.15.

Source Code

This filter is located in GFEntryList::get_filter_links() in entry_list.php.