Sometimes it might be helpful to make the website visitor tick a checkbox to accept terms before allowing a file upload.
You must check this box before you can upload a file.
Go ahead, check it.
If you are at all comfortable with doing a little coding, this can be accomplished with some simple JavaScript added to your theme and HTML in the page content. Here’s how:
Page Content
Place an HTML block above the Simple File List shortcode. This is simply a checkbox followed by your message. You can add a link to the full text if you want.
<p>
<input id="myCheckToUpoad" type="checkbox" name="Checkbox" value="YES">Check this Box.
</p>
JavaScript in your Theme
The key to the code above is the id="myCheckToUpoad"
. The JavaScript will hook into this and show or hide the upload form. You could also use this for the file list, or both.
Locate your current theme’s functions.php file.
Add this code, then save.
// Function to output JavaScript in theme <head>
function myHeadHurts() { ?>
<script>
jQuery(document).ready(function() {
jQuery('#eeSFL_UploadForm').hide(); // Hide the form straight away
jQuery('#myCheckToUpload').on('click', function() { // The box is clicked...
// Either show or hide, depending if ticked or not
if (jQuery('#eeSFL_UploadForm').is(':visible')) {
jQuery('#eeSFL_UploadForm').slideUp(); // Hide
} else {
jQuery('#eeSFL_UploadForm').slideDown(); // Show
}
});
}); // END Ready Function
</script>
<?php }
// Hook into WordPress loading process
add_action('wp_head', 'myHeadHurts'); // Add to the page's <head>
There are many improvements that could be made to this example, but this is basically all you need to get started.