This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
Use this hook to allow filtering the args of FrmPdfsAppController:generate_entry_pdf() method when adding email attachments.
Usage
add_filter( 'frm_pdfs_email_attachment_args', 'custom_function', 10, 2 );
Parameters
- $pdf_args (array): The args of FrmPdfsAppController::generate_entry_pdf() method.
- $args (array):
- form (object): Form object.
- entry (object): Entry object.
- email_key (string): Email key.
- settings (array): Email action settings.
- action_id (int): Email action ID.
Examples
Apply View as the PDF email attachment
Use this code snippet if you're looking to attach a custom PDF to your email. Note that you need to have PDF attachment settings enabled in your email settings first.
add_filter( 'frm_pdfs_email_attachment_args', 'add_view_to_attached_pdf', 10, 2 );
function add_view_to_attached_pdf( $pdf_args, $args ) {
if($args['form']->id ==5) { //change 5 to the ID of the form
$pdf_args['view'] = 10; // ID of view.
$pdf_args['id'] = $args['entry']->id; // Do this to show the detail view, otherwise, it shows the listing view.
return $pdf_args;
}
}
Change the attached PDF file name
add_filter( 'frm_pdfs_email_attachment_args', 'change_attached_pdf_file_name', 10, 2 );
function change_attached_pdf_file_name( $pdf_args, $args ) {
$pdf_args['filename'] = 'stuff';
return $pdf_args;
}