I posted this in the general questions but it's getting very technical (for my limited experience) so I thought posting in CODE HELP might be a better option. I have multiple forms that each have a View created for custom PDF attachments in emails. Currently using this style shortcode [frm-pdf view=574 entry="[id]" public=1] it is using the View layout for the Download PDF link that appears on the confirmation landing page for BOTH forms (see screenshots) but it is only sending the View layout PDF as email attachments for form ID7. Form ID6 is still sending the standard layout and ignoring the view layout (screenshots attached for this as well). Here is the code I currently have in my functions.php file:
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 ==6) { //change 5 to the ID of the form
$pdf_args['view'] = 554; // 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;
}
}
add_filter( 'frm_pdfs_email_attachment_args', 'add_view_investius_pdf', 10, 2 );
function add_view_investius_pdf( $pdf_args, $args ) {
if($args['form']->id ==7) { //change 5 to the ID of the form
$pdf_args['view'] = 574; // 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;
}
}
Can anyone tell me where I am going wrong? I used the following links to try to work it out myself but I'm obviously doing something wrong: https://formidableforms.com/knowledgebase/formidable-hooks/#kb-duplicating-a-function https://formidableforms.com/knowledgebase/frm_pdfs_email_attachment_args/#kb-apply-a-view-for-the-attached-pdf
add_filter( 'frm_pdfs_email_attachment_args', 'add_view_to_attached_pdf', 10, 2 ); function add_view_to_attached_pdf( $pdf_args, $args ) { $args_set = false; switch($args['form']->id) { case 6: $pdf_args['view'] = 554; $args_set = true; break; case 7: $pdf_args['view'] = 574; $args_set = true; break; default: break; } if ($args_set) { $pdf_args['id'] = $args['entry']->id; // Do this to show the detail view, otherwise, it shows the listing view. return $pdf_args; } }
Thank you Rob, I'm so relieved I could cry - it is finally working with this code! You saved me 🙂
Please login or Register to submit your answer