Modifying the entries displayed in a View
GravityView provides the gravityview/view/entries
filter which can be used to modify entries before they are displayed on the View.
Below is a code snippet that can be used as a boilerplate for custom modifications:
add_filter( 'gravityview/view/entries', 'gv_filter_gravityview_view_entries', 10, 3 ); /** * * @param \GV\Entry_Collection $entries The entries for this view. * @param \GV\View $view The view. * @param \GV\Request $request The request. * * @return \GV\Entry_Collection */ function gv_filter_gravityview_view_entries( $entries, $view = null, $request = null ) { // Only filter entries for View #123 if( 123 !== $view->ID ) { return $entries; } if( ! $entries instanceof \GV\Entry_Collection ) { return $entries; } // There's no way to remove entries from a collection; instead, we just create a new one $return = new \GV\Entry_Collection(); foreach( $entries->all() as $entry ) { // Your custom code here! } return $return; }