• Resolved gthreedev

    (@gthreedev)


    I already have set the Always Save PDF to Yes on the settings but it’s not showing up on /wp-content/uploads/PDF_EXTENDED_TEMPLATES/tmp

    I also created a code that will save a copy of the pdf on a different folder but it doesn’t seem to work also

    function gfpdfe_post_pdf_save($form_id, $lead_id, $arguments, $filename)
    {
      
         
        $pdf_name = basename($filename);
     
        if($form_id == '1')
        {
            $form = RGFormsModel::get_form_meta($form_id);
            $form_title = $form['title'];  
    		
    		GFCommon::log_debug( 'patlog: form title: ' . $form_title );
    		GFCommon::log_debug( 'patlog: pdf name: ' . $pdf_name );
            copy($filename, '/' . $form_title. '/' . $pdf_name);       
        }
    }
     
    add_action('gfpdf_post_pdf_save', 'gfpdfe_post_pdf_save', 10, 4);
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jake Jackson

    (@blue-liquid-designs)

    Hi there,

    The Always Save PDF setting is available so that the use of <a href="https://docs.gravitypdf.com/v5/gfpdf_post_save_pdf">gfpdf_post_save_pdf</a> is consistently triggered when a form is submitted. But the PDF that is saved to the tmp PDF directory is still automatically cleaned up once the submission process is completed in full. This is why you don’t see the PDF when looking in /wp-content/uploads/PDF_EXTENDED_TEMPLATES/tmp/ (it’s already been saved and deleted).

    As for why your filter isn’t working, it’s because you haven’t created the directories before attempting to copy the PDF. Looks like that code snippet you are using is outdated, as the current example in the docs solves this problem for you: https://docs.gravitypdf.com/v5/gfpdf_post_save_pdf

    Thread Starter gthreedev

    (@gthreedev)

    Thank you for your response, I already tested the example from https://docs.gravitypdf.com/v5/gfpdf_post_save_pdf but still the no copies have been ;
    created on the folder that I created. This is the exact code that I’m using right now:
    NOTE: the form id is 1 and I already created the folder on the root folder.

    add_action( 'gfpdf_post_save_pdf', function( $pdf_path, $filename, $settings, $entry, $form ) {
    
        if ( '1' == $form['id'] ) {
            /* The directory we want to copy our PDF to */
            $copy_to_dir = ABSPATH . 'PDFs/';
    
                /* Create the directory if it doesn't exist */
                if( ! is_dir( $copy_to_dir ) ) {
                    wp_mkdir_p( $copy_to_dir );
                }
    
            /* Ensure we get a unique filename for the directory we are copying to */
            $filename = wp_unique_filename( $copy_to_dir, $filename );
    
            /* Copy the PDF to the new directory */
            copy( $pdf_path, $copy_to_dir . $filename );
        }
    
    }, 10, 5 );
    Plugin Author Jake Jackson

    (@blue-liquid-designs)

    If the filter isn’t working the way you expect then you will need to debug it. Start by checking if it’s actually running during form submission by including an echo statement that will output a message on screen for you to easily see. Then check if the conditional is passing using the same method. Keep following this approach until you’ve checked every function is being executed and returning the appropriate results.

    You can then enable WordPress Debugging and see if any error are being generated. This can help narrow down what the problem may be.

    Good luck getting it setup how you need!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PDFs won’t save’ is closed to new replies.