gpfr_filename

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Global Filename Template
    2. Lowercase All Filenames
  5. Since

Description

Filter the renamed filename.

Usage

Apply to all fields and forms.

add_filter( 'gpfr_filename', 'my_custom_function', 10, 3 );

Apply to all fields on a specific form.

add_filter( 'gpfr_filename_FORMID', 'my_custom_function', 10, 3 );

Apply to a specific field on a specific form.

add_filter( 'gpfr_filename_FORMID_FIELDID', 'my_custom_function', 10, 3 );

Parameters

  • renamed_file string

    Renamed filename.

  • file string

    The original filename.

  • entry array

    The properties of the entry including field values.

  • form array

    The current form.

  • field \GF_Field

    The current field.

Examples

Global Filename Template

<?php
/**
 * Gravity Perks // File Renamer // Global Filename Template
 * https://gravitywiz.com/documentation/gravity-forms-file-renamer/
 *
 * This snippet puts all files in an entry-specific subfolder and increments the filename with its count.
 *
 * Requires GP File Renamer v1.0.5+.
 */
add_filter( 'gpfr_filename_template', function ( $template, $filename, $form, $field, $entry ) {
	return '{entry:id}/{filename}-{i}';
}, 10, 5 );

Lowercase All Filenames

<?php
/**
 * Gravity Perks // GP File Renamer // Lowercase All Filenames
 * https://gravitywiz.com/documentation/gravity-forms-file-renamer/
 *
 * This snippet will automatically lowercase all filenames.
 */
add_filter( 'gpfr_filename', function( $renamed_file, $file, $entry ) {
	return strtolower( $renamed_file );
}, 10, 3 );

Since

This filter is available since Gravity Forms File Renamer 1.0.

The $form and $field parameters were added in File Renamer 1.0.5.