Keep up to date with Gravity PDF

  • This field is for validation purposes and should be left unchanged.
This is the legacy Gravity PDF v4 documentation which is NOT supported. Go to the latest documentation.
Jump To Section

Description #description

By default temporary files Gravity PDF creates are stored in the tmp folder inside the PDF working directory. As we discussed in the PDF security documentation this directory is protected from direct access by a .htaccess file. However, this only works for web servers running Apache or Litespeed. This filter allows you to move this folder to a private directory that isn’t accessible from the web, ensuring your PDFs stay private.

Note: your web server needs write access to the folder you move this directory to.

Parameters #parameters

$path | string
The path to the tmp folder.
$working_folder | string
The working directory folder name. By default this is PDF_EXTENDED_TEMPLATES.
$upload_path | string
The path to your uploads directory (where the PDF working directory is stored by default).

Usage #usage

The following snippet shows you how you can move the PDF temporary directory to a private folder that’s not accessible through a browser:

add_filter( 'gfpdf_tmp_location', function( $path, $working_folder, $upload_url ) {
     * On a standard WordPress installation the ABSPATH directory refers to the top-level directory on your web server
     * where WordPress is located. When that's the case, going up a directory and creating the tmp folder usually means it becomes private.
     * Depending on your web server setup you may need to modify this path to ensure it's not accessible through your browser.
     * Make sure you include the forward slash at the end!
     return ABSPATH . '../GravityPDF/tmp/';

      * If the above doesn't work, you can try use the get_temp_dir() function instead
     return get_temp_dir();

}, 10, 3 );

Once you’ve verified the filter works correctly you should manually remove the old directory.

Source Code #source-code

This filter is located in the Model_Install::setup_template_location() method of /src/model/Model_Install.php.

Signup for the latest Gravity PDF news, tips and updates

  • This field is for validation purposes and should be left unchanged.
Gravity PDF 40K Active Installs Celebration! Take 20% off any products with coupon 40KMILESTONE (this week only)Visit Store
+ +
Scroll To Top

Choose your currency:

Converted prices are for reference only - all orders are charged in $ Australian Dollars ($) AUD.
  • AUDAustralian Dollars ($)
  • USDUS Dollars ($)
  • CADCanadian Dollars ($)
  • EUREuros (€)
  • GBPPound Sterling (£)
  • NZDNew Zealand Dollar ($)
  • JPYJapanese Yen (¥)