Hi,
Have you followed the instructions on setting up the plugin, including notifications, here: http://gravityformspdfextended.com/documentation/2.0.0/1/configuration/
You’ll also need to enable notifications in your form.
Let me know if you have any problems.
Yes, I followed those directions but it’s not working. Well…it’s saving, but not attaching. I changed if($form_id == 1) to if($form_id == 4) [the id of my form] but nothing. Are there any other variables I need to change?
I’ve compared the Notifications screen of my form to that of the example form and they’re identical. I’ve also compared the form settings. Identical.
This is the code I’ve added to my theme’s functions.php
function gform_pdf_create($entry, $form)
{
$user_id = $entry['id'];
$form_id = $entry['form_id'];
/* only output PDF if the $form_id matches */
/* 4 is the ID for the second half of the contract */
if($form_id == 4)
{
/* include the pdf processing file */
require PDF_PLUGIN_DIR.'render_to_pdf.php';
/* generate and save default PDF */
//$filename = PDF_Generator($form_id, $user_id, 'save', true);
/* comment out the above line and uncomment the line below if you want to use a custom template */
$filename = PDF_Generator($form_id, $user_id, 'save', true, 'example-template.php', 'EasternEdgePolicyContract.pdf');
}
}
add_action("gform_entry_created", "gform_pdf_create", 10, 2);
and
function gform_add_attachment($attachments, $lead, $form){
$form_id = $lead['form_id'];
$user_id = $lead['id'];
$attachments = array();
$folder_id = $form_id.$user_id.'/';
/* 4 is the ID of the second half of the contract */
if($form_id == 4)
{
/* include PDF converter plugin */
include PDF_PLUGIN_DIR.'render_to_pdf.php';
//$attachment_file = PDF_SAVE_LOCATION. $folder_id . get_pdf_filename($form_id, $user_id);
$attachment_file = PDF_SAVE_LOCATION. $folder_id . 'FormName.pdf';
$attachments[] = $attachment_file;
}
return $attachments;
}
/* add attachment to both the admin and user notification */
add_filter("gform_admin_notification_attachments", 'gform_add_attachment', 10, 3);
add_filter("gform_user_notification_attachments", 'gform_add_attachment', 10, 3);
Can you help any more?
Hi Mel,
You’re using a custom template name but forgot to tell the attachment function to use the new name.
Change $attachment_file = PDF_SAVE_LOCATION. $folder_id . 'FormName.pdf';
to $attachment_file = PDF_SAVE_LOCATION. $folder_id . 'EasternEdgePolicyContract.pdf';
and you should be fine.
Thanks! Figures it was a simple oversight. Now… do you know if there’s anyway to access that PDF from a browser after it’s been generated? The URL is giving me a 404 even though I can see the file on the server. I need to open up the PDF so that the user can print it (through the website, not through their email program).
PDFs on the server are protected via the .htaccess file to stop unwanted people downloading the PDFs. The most secure way to do it is to generate the PDF automatically. There’s a description on how to do this in our FAQs: http://gravityformspdfextended.com/faq/i-want-users-to-be-able-to-download-the-pdf-from-the-server/
That’s close to what I was doing (using $_GET to get the form and entry ID to build the url) but that will make all the difference. Thanks again!