This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
(Since version 5.0.12) Use this hook to remove protection for temporary files.
Usage
add_filter( 'frm_protect_temporary_file', '__return_false' );
Parameters
- $protect
- $args (array)
- form_id
- field_id
Examples
Unprotect temporary files for one form
Use this example to turn protection off for images on a single form.
add_filter( 'frm_protect_temporary_file', 'unprotect_temporary_files', 10, 2 );
function unprotect_temporary_files( $protect, $args ) {
$target_form_id = 117; // change 117 to the ID of your form
if ( $target_form_id === (int) $args['form_id'] && FrmProFileField::file_is_an_image( $args['file_id'] ) ) {
$protect = false;
}
return $protect;
}
Unprotect temporary files for all forms
Use this example to turn protection off for images on all forms. It will leave all images unprotected always. This example is beneficial in cases where you want to avoid plugin conflicts to prevent metadata file conflicts.
add_filter( 'frm_protect_temporary_file', 'unprotect_temporary_files', 10, 2 );
function unprotect_temporary_files( $protect, $args ) {
if ( FrmProFileField::file_is_an_image( $args['file_id'] ) ) {
$protect = false;
}
return $protect;
}
Basic Example
(Not recommended). If logged-out users can submit entries in your form, those file uploads will be publicly available. It can be unsafe, especially if you are allowing PDF uploads.
Use this example if you have set up your uploads to go to S3 or another CDN. You can then control those uploads from your CDN settings. Note: We don't have control of access to those files.
add_filter( 'frm_protect_temporary_file', '__return_false' );