PDF for GravityView Hooks – gfpdf_gv_multiple_entries_limit
Description
Change the maximum number of entries in a Multiple Entries PDF. The default is 500, whatever the View holds or the widget or link asks for. The limit exists because the PDF link works without logging in, and one very large PDF can tie up your server. Raise it for a View you trust, or lower it on a busy site.
The limit applies however the PDF is requested (see How Many Entries Are Included). The PDF includes the first entries up to the limit, in the View's sort order.
Raising the limit doesn't add larger choices to the widget's "Number of Entries to Display" dropdown. Add those with gfpdf_gv_multiple_entries_page_size_options. The "Display all" label does show the new limit, such as "Display all (up to 1,000)".
Larger PDFs cost more to generate and use up a visitor's render budget faster. If you raise the limit well past 500, consider raising gfpdf_gv_render_budget and check your server's PHP memory and time limits.
Version
This hook was introduced in PDF for GravityView 2.0.
Arguments
The following arguments are passed to functions that use this hook:
$limit | int
- The most entries a Multiple Entries PDF will include.
- A value below 1 is treated as 1.
- The default value is
500.
$view | \GV\View | null
- The View the PDF is being generated for.
- It's
nullwhen the widget's settings are built, before any View is known. The dropdown labels and choices use the limit you return fornull.
Usage
Allow up to 2,000 entries in View 885's Multiple Entries PDF, and keep the default for every other View:
add_filter( 'gfpdf_gv_multiple_entries_limit', function( $limit, $view ) {
if ( $view && (int) $view->ID === 885 ) {
return 2000;
}
return $limit;
}, 10, 2 );
Source Code
This filter is located in src/GravityView/PdfLinkSettings.php of the PDF for GravityView extension.