Keep up to date with Gravity PDF

  • This field is for validation purposes and should be left unchanged.

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/';

}, 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.
Scroll To Top

Choose your currency:

Close
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 (¥)