Can I Force Acceptance of Terms Before Viewing or Uploading Files?

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.

Upload Files

Processing the Upload

File Limit: 3 files
Size Limit: 100 MB per file.
Types Allowed: aiff, doc, docx, gif, jpg, jpeg, mp3, mp4, mov, pdf, png, tif, tiff, zip
Drag-and-drop files here or use the Browse button.

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.

Let me know if you need help.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.