Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phillipwilhelm/d350103ce9ce7aaccfbd92642207f41e to your computer and use it in GitHub Desktop.
Save phillipwilhelm/d350103ce9ce7aaccfbd92642207f41e to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Field-specific Upload Path (Simple)
<?php
/**
* Gravity Wiz // Gravity Forms // Field-specific Upload Path
*
* Provides a method for specifying field-specific file upload paths.
*
* @version 1.0
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
*/
class GF_Field_Specific_File_Upload_Path {
var $current_field_id = null;
function __construct() {
add_filter( 'gform_save_field_value', array( $this, 'stash_current_field_id' ), 10, 3 );
add_filter( 'gform_upload_path', array( $this, 'modify_upload_path' ) );
}
function stash_current_field_id( $value, $entry, $field ) {
$this->current_field_id = $field['id'];
}
function modify_upload_path( $upload_path ) {
// modify the upload path based on the current field ID:
// $current_field_id = $this->current_field_id
return $upload_path;
}
}
new GF_Field_Specific_File_Upload_Path();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment