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

A user requested a feature that would make the website visitor tick a checkbox to accept terms of service and privacy policy 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: 99 files
Size Limit: 10 MB per file.
Types Allowed: gif, jpg, jpeg, png, pdf, mp4, mov, 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 uploader. 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 myHead() { ?>

<script>
jQuery(document).ready(function() {

jQuery('#eeUploadForm').hide(); // Hide the form straight away
 
jQuery('#myCheckToUpoad').click(function() { // The box is clicked...

     // Either show or hide, depending if ticked or not       
     if (jQuery('#eeUploadForm').is(':visible')) { 

         jQuery('#eeUploadForm').slideUp(); // Hide

        } else {

             jQuery('#eeUploadForm').slideDown(); // Show
     }

    });

}); // END Ready Function

</script>

<?php }

// Hook into WordPress loading process
add_action('wp_head', 'myHead'); // 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.