Last active
April 24, 2019 13:22
-
-
Save Shelob9/45233a83571a937e569ba6c6f92dd8b5 to your computer and use it in GitHub Desktop.
Examples of how to set an alternative file upload path for Caldera Forms file fields. See: https://calderawp.com/doc/caldera_forms_upload_directory/
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 | |
add_filter( 'caldera_forms_upload_directory', function(){ | |
return 'form-uploads'; | |
}); |
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 | |
add_filter( 'caldera_forms_upload_directory', function( $dir, $field_id ){ | |
if( 'fld_1233444' == $field_id ){ | |
$dir = 'form-uploads'; | |
} | |
return $dir; | |
}, 10, 2 ); |
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 | |
add_filter( 'caldera_forms_upload_directory', function( $dir, $field_id, $form_id ){ | |
$field = Caldera_Forms_Field_Util::get_field( $field_id, Caldera_Forms_Forms::get_form( $form_id ) ); | |
if ( is_array( $field ) ) { | |
$dir = sanitize_title( $field[ 'slug' ] ); | |
} | |
return $dir; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment