• Dear Jake,
    Sorry but I am at a loss I am using Avada Theme and have put the following code in child function.php theme but all I get on submit of the form is is message saying ” Form ID and Lead ID are required”

    The id of the form is 2

    There does not seem to be any new pdf created on the server, can you help as I am at a bit of a loss

    Iam using GF 1.7.5 and the latest version 2.2.3 of GF PDF Extended. The site is at https://www.psweb-test4.com/?page_id=157

    <?php

    function gfpdfe_create_and_attach_pdf($notification, $form, $entry)
    {

    /*
    * Set the PDF name here or leave blank to use the default.
    * Example: $PDF_name = ‘My File.pdf’;
    */
    $PDF_name = ”;

    /*
    * Use a custom template or leave blank to use the default.
    * The template file needs to be in your active theme’s PDF_EXTENDED_TEMPLATES folder before referencing below
    * Example: $custom_template_name = ‘my-custom-template.php’;
    * Default template options: default-template.php, default-template-two-rows.php, default-template-no-style.php
    */
    $template_name = ‘default-template.php’;

    /*
    * Set data used to determine if PDF needs to be created and attached to notification
    * Don’t change anything here.
    */
    $notification_name = $notification[‘name’];
    $notification_id = $notification[‘id’];
    $form_title = $form[‘title’];
    $form_id = $entry[‘form_id’];
    $user_id = $entry[‘id’];
    $folder_id = $form_id.$user_id.’/’;

    /* GENERATE AND EMAIL PDF
    * Do we want to create and send a PDF for this form?
    * You can match the form ID or the form title
    * Example: if($form_id == 3 || $form_title == ‘My Custom Form’)
    */
    if ($form_id == 2) {
    /*
    * Get ready to create the PDF file
    */
    require PDF_PLUGIN_DIR . ‘render_to_pdf.php’;
    $PDF_name = (strlen($PDF_name) > 0) ? $PDF_name : get_pdf_filename($form_id, $user_id);
    $pdf_arguments = array(
    ‘pdfname’ => $PDF_name,
    ‘template’ => $template_name,
    ‘return’ => true
    );

    /* generate and save default PDF */
    $filename = PDF_Generator($form_id, $user_id, $pdf_arguments);

    /* ATTACH PDF TO EMAIL
    * As of GF 1.7 notifications aren’t limited to admin and user.
    * We now need to match the notification we would like to attach the file to instead of using gform_admin_notification_attachments and gform_user_notification_attachments.
    * You can match against the name of your notification
    * Example: if($notification_name == ‘Admin – Notify admin user’)
    */
    if ($notification_name == ‘Admin Notification’ || $notification_name == ‘User – Notify User’) {
    $attachment_file = PDF_SAVE_LOCATION . $folder_id . $PDF_name;
    $notification[‘attachments’][] = $attachment_file;
    }
    }
    return $notification;
    }

    add_filter(‘gform_notification’, ‘gfpdfe_create_and_attach_pdf’, 10, 3);

    ?>

    https://www.ads-software.com/extend/plugins/gravity-forms-pdf-extended/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jake Jackson

    (@blue-liquid-designs)

    Hi,

    I just tested the install code you posted with the latest version of Gravity Forms and didn’t have any issues.

    Since you are getting the message “Form ID and Lead ID are required” I recommend you copy the template files from the plugin folder – wp-content/plugins/gravity-forms-pdf-extended/templates/ to the PDF_EXTENDED_TEMPLATES folder in your active theme’s directory and try again.

    Thread Starter condonp

    (@condonp)

    That seems to done it many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PDF Not Working’ is closed to new replies.