Dear Formidable Community,
We are intensive users of Formidable and greatly appreciate the functionality it provides. However, we had a specific need regarding the protection of uploaded files. Most of the files uploaded through our forms need to be protected, but our users often forgot to check the “Protect files” checkbox. Considering that this checkbox needs to be checked 99% of the time, we sought a way to have the “Protect files” checkbox marked by default.
To resolve this issue, we developed our own plugin to enforce file protection by default. Below is the code we are using:
<?php
/*
Plugin Name: Formidable Force File Protection
Description: Forces file protection for file uploads in Formidable Forms.
Version: 1.0
Author: Ernesto
*/
// Hook to force file protection when creating a new form entry
add_action('frm_after_create_entry', 'force_file_protection_on_create', 20, 2);
function force_file_protection_on_create($entry_id, $form_id) {
// Get the values of the newly created form entry
$values = FrmEntry::getOne($entry_id, true);
// Force file protection and no indexing
$values->options['protect_files'] = 1; // Force file protection
$values->options['noindex_files'] = 1; // Force no indexing of files
// Update the entry with the new values
FrmEntry::update($entry_id, array('options' => $values->options));
}
?>
This solution has helped us ensure that files are protected by default. We are sharing this in case it can be useful to other users with similar requirements.
Thank you very much for your consideration.
Best regards,
Ernesto