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 list don't get the Exclude from PDF? and Only Include in PDF? checkboxes in the View editor. A type you add loses them, and a type you remove gets them back. Before version 2.0.1, the checkboxes followed the default list, not the filtered one.
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', 'rate_entry', 'workflow_approval_links' ]: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 formrate_entry: the Ratings & Reviews extension's Rate Entry form (added in 2.0.1)workflow_approval_links: Gravity Flow's Workflow Approval Links field (added in 2.0.1)
$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/GravityView/Fields/Exclusions.php of the PDF for GravityView extension.