• Is there a way to download pdf instantly after clicking “send”? I also don’t want this pdf to be stored on my server. I just want user to fill the forms, download desired PDF and that’s it. Without saving any files.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author maximum.software

    (@maximumsoftware)

    There is a feature that you can turn on (see options) to add a download link for the filled PDF into the response message. Users can then click the link to download the PDF. (Although, that feature has been a bit mangled by CF7 version 5.4 but I am working on a fix that I will release soon).

    The PDF files are saved to the server but only temporarily. The download link PDF files are deleted automatically after a day. Why is it important for you to not have the files temporarily stored on the server?

    Plugin Author maximum.software

    (@maximumsoftware)

    I’ve released a new version that fixes the download link feature in CF7 v5.4.

    Thread Starter vestonmedia

    (@vestonmedia)

    Now downloading document works great.

    “Why is it important for you to not have the files temporarily stored on the server?”
    -> Our website was built for filling up government documents and in order for users to fill it up, they have to input their personal data, like ID number. On what line of code I can change it from deleting after one day to deleting after 30 seconds or instantly after clicking download?

    Plugin Author maximum.software

    (@maximumsoftware)

    I don’t think you need to worry about this.

    The files are stored in ‘wpcf7_pdf_forms_downloads’ folder in your WP uploads folder. Each form submission has its own randomly named folder. If an unauthorized person wanted to download the generated PDF files, they would at least need to guess the randomized folder name. The folders should be deleted after 24 hours by WordPress cron.

    If you really need those files to be deleted ASAP, you can set up a cron job to run every minute with the following code:

    
    <?php
    
    define('WPCF7_PDF_FORMS_DOWNLOADS_TIMEOUT_SECONDS', 30);
    require_once( 'wp-load.php' );
    WPCF7_Pdf_Forms::get_instance()->cron();
    

    Let me know if that works for you.

    Thread Starter vestonmedia

    (@vestonmedia)

    Where should I add this code? When I tried to add it at the end to pdf-forms-for-contact-form-7.php file, I get a ton of errors. I know only the basics of programming, so I’m not really sure if I do it at the right place

    Plugin Author maximum.software

    (@maximumsoftware)

    You will need to put this code in a separate PHP file somewhere in your hosting environment and then create a cron job to run that file. If you have cPanel, you can set up a cron job using the web UI.

    Here is a random tutorial for doing the above that I found via a search engine:
    https://www.cluemediator.com/set-the-cron-job-to-run-a-php-script-in-cpanel

    Thread Starter vestonmedia

    (@vestonmedia)

    Unfortunately, but that doesn’t work for me. I asked my hosting support to add cron job, but the files are still not deleted.

    Do you have any other ideas?

    • This reply was modified 3 years, 11 months ago by vestonmedia.
    Plugin Author maximum.software

    (@maximumsoftware)

    I think I know what your problem is. Can you put your PHP file in the same directory that has the ‘wp-load.php’ file and add chdir as shown below:

    <?php
    
    define('WPCF7_PDF_FORMS_DOWNLOADS_TIMEOUT_SECONDS', 30);
    chdir(__DIR__);
    require_once( 'wp-load.php' );
    WPCF7_Pdf_Forms::get_instance()->cron();
    

    Make sure you update your cron job to point to the file in the correct folder.

    Thread Starter vestonmedia

    (@vestonmedia)

    Still nothing. Maybe the hosting owners do something wrong, but i’m not sure. Is there an easier way to do it? With some kind of plugin or something?

    Plugin Author maximum.software

    (@maximumsoftware)

    It works for me. One thing I can do is look at your setup and try to debug it.

    If you send me temporary cPanel login details to admin at maximum dot software then I will do some debugging.

    Thread Starter vestonmedia

    (@vestonmedia)

    My hosting doesn’t provide CPanel unfortunately and there is no option to add Cron Job from the panel. Are you planning an update to add such a feature? So in the Contact Form 7 the administrator will be able to choose the time after which the files will be deleted?

    Plugin Author maximum.software

    (@maximumsoftware)

    Technically speaking, adding the following to your wp-config.php file should be sufficient:

    define('WPCF7_PDF_FORMS_DOWNLOADS_TIMEOUT_SECONDS', 30);

    However, due to a limitation in wp-cron scheduling in my plugin, this will not work.

    I have added a fix earlier today to make it work (see my commit on GitHub). However, I will need to do some more testing before I make a release with the fix. You may be able to apply the patch to your files manually. If you are having difficulties with this, send me temporary wp-admin login details to my email mentioned above and I will log in and try it out on your WP instance.

    Thread Starter vestonmedia

    (@vestonmedia)

    I added this changes manually, but now i get this error:
    Fatal error: Uncaught Error: Call to a member function get_status() on null in /home/tlumacz8/domains/domain.pl/public_html/wp-content/plugins/pdf-forms-for-contact-form-7/pdf-forms-for-contact-form-7.php:1951 Stack trace: #0 /home/tlumacz8/domains/domain.pl/public_html/wp-includes/class-wp-hook.php(294): WPCF7_Pdf_Forms->change_response_nojs(‘

    I guess, i will just wait for the next release with such an option. When are you planning on adding that? I would give you the access to our website, but right now we are working on a testing domain. Official website is planned to be released on 18 of April.

    Plugin Author maximum.software

    (@maximumsoftware)

    @vestonmedia, I’ve released a new version that has cron scheduling fixes. You should be able to use define('WPCF7_PDF_FORMS_DOWNLOADS_TIMEOUT_SECONDS', 30); in your wp-config.php and get those files automatically deleted with the new version.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Automaticly download pdf after clicking “send”’ is closed to new replies.