• Resolved quoindesign

    (@quoindesign)


    Hi, I’ve carefully (I think) followed your configuration instructions on your web site, and can’t get your plugin operating. Here’s the functions.php code I currently have. I’ve checked the form ID several times. I want to use default PDF name and template, and I want the PDF to attach to every notification.

    What am I doing wrong?

    /*Gravity Forms PDF Extended Code */
    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 == 1) {
            /*
             * 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 or the ID
             * Example: if($notification_name == 'Admin - Notify admin user' || $notification_id == '5137b95689b2e')
             */
                $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);

    Thanks!

    http://wordpress.org/extend/plugins/gravity-forms-pdf-extended/

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

    (@blue-liquid-designs)

    Hi,

    Can you confirm what version of Gravity Forms you are using? The stable release is 1.6.12 and you’ve used the 1.7 Beta code.

    You can find the 1.6.12 installation instructions/code here http://gravityformspdfextended.com/documentation/installation/configuration/#gravity-forms-1-6-12

    Thread Starter quoindesign

    (@quoindesign)

    I made an assumption about what version of GravityForms I was using! Okay, it’s generating the PDF and also attaching.

    Thank you!

    Plugin Author Jake Jackson

    (@blue-liquid-designs)

    No problem.

    Hello, i have the same problem, still not working for me, I have version 2.2.3 and GF 1.7.2.

    I double checked everything, inserted this code in functions.php inside my theme files, before php tag, please take a look. The PDF is not being created neither attached. I used the ID and the tittle when needed. Wrote the notification tittle for the user and the admin:

    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 Custom Document.pdf';
         */
        $PDF_name = 'My Custom Document.pdf';
    
        /*
         * 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 == 2 || $form_title == 'Let me Know What Do You Need')
         */
        if ($form_title == 'Let me Know What Do You Need') {
            /*
             * 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 Notification') {
                $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);
    
    <?php }
    ?>

    Please help… I couldn’t make this work for me.

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