Created
July 21, 2014 14:18
-
-
Save spivurno/35b86c47cdf0124be735 to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Field-specific Upload Path (Simple)
This file contains 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 <david@gravitywiz.com> | |
* @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
How do I use this in my gravity form?