How to modify the entries displayed in a View

GravityView fetches entries using the gravityview_get_entries() function

The gravityview_get_entries() is a wrapper for the GVCommon::get_entries() method.

GravityView uses GVCommon::get_entries() as a wrapper to generate a request before sending it to Gravity Forms' GFAPI::get_entries(). This way, we can add lots of nice filters, provide caching functionality, and ensure the search is generated properly.

The method has two filters: gravityview_search_criteria and gravityview_entries.

The gravityview_search_criteria filter

Modify the arguments used to generate the search. These arguments are also used to generate the cache key.

  • $criteria - Search array with the following keys:
    • search_criteria - Array; see GFAPI::get_entries() method for details
    • sorting - Array with key (field ID), direction (ASC or DESC), and is_numeric (boolean) keys
    • paging - Array with offset and page_size keys. See GFAPI::get_entries()
    • cache - Set to 0 or false to disable caching of results. Default: 1
  • $form_ids - The ID of the form or an array IDs of the forms. Zero (0) for all forms.

The gravityview_entries filter

Modify the array of entries returned to GravityView after it has been fetched from the cache or from GFAPI::get_entries().

  • $entries array or null Array of entries as returned by the cache or by GFAPI::get_entries()
  • $criteria array The final search criteria used to generate the request to GFAPI::get_entries()
  • $passed_criteria array The original search criteria passed to GVCommon::get_entries()
  • $total int or null Optional. An output parameter containing the total number of entries. Pass a non-null value to generate