Forked from spivurno/gw-gravity-forms-field-specific-file-upload-path-simple.php
Created
September 5, 2016 04:54
-
-
Save phillipwilhelm/d350103ce9ce7aaccfbd92642207f41e to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Field-specific Upload Path (Simple)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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