PDF for GravityView Hooks – gfpdf_gv_internal_fields_to_skip
Description
Add or remove field types from the list PDF for GravityView always leaves out of the PDF. The list holds GravityView's on-screen links and controls, such as Edit Entry, Delete Entry and the PDF link. Add a type when your plugin registers a field that only makes sense on screen.
The list applies to the Single Entry PDF and the Multiple Entries PDF. Field types on the default list don't get the Exclude from PDF? checkbox in the View editor, and the filtered list doesn't change that. A type you remove is always printed, with no checkbox to hide it. A type you add keeps its checkbox, which then has no effect.
For decisions that depend on the entry, the user or which PDF is being generated, use gfpdf_gv_field_middleware instead.
Version
This hook was introduced in PDF for GravityView 0.2.
Arguments
The following arguments are passed to functions that use this hook:
$fields_to_skip | array
- The GravityView field types to leave out of the PDF, matched against
$field->type. - The default value is
[ 'pdf_link', 'pdf_email', 'edit_link', 'duplicate_link', 'delete_link', 'entry_approval', 'unsubscribe', 'gravity_forms' ]:pdf_link: the Link to Single Entry PDF fieldpdf_email: the Share Single Entry PDF fieldedit_link,duplicate_link,delete_link: GravityView's Edit Entry, Duplicate Entry and Delete Entry linksentry_approval: the approve/disapprove controlunsubscribe: the Unsubscribe linkgravity_forms: GravityView's Gravity Forms field, which embeds a form
$field | \GV\Field
- The View field being checked. The filter runs once per field.
Usage
Leave your own my_rsvp_button field type out of every PDF:
add_filter( 'gfpdf_gv_internal_fields_to_skip', function( $fields_to_skip, $field ) {
$fields_to_skip[] = 'my_rsvp_button';
return $fields_to_skip;
}, 10, 2 );
Keep the Edit Entry link in the PDF, so staff can click through from a saved PDF to the entry:
add_filter( 'gfpdf_gv_internal_fields_to_skip', function( $fields_to_skip, $field ) {
return array_values( array_diff( $fields_to_skip, [ 'edit_link' ] ) );
}, 10, 2 );
Source Code
This filter is located in src/Pdf/FieldMiddleware.php of the PDF for GravityView extension.