USP Pro enables your visitors to submit many different types of files. In fact, as USP Pro is built using WP APIs, it supports any file types that are supported by WordPress. So continuing from USP Pro Custom Fields, this article explains how to set up the fields required for custom file types, and how to display them anywhere in your theme template.

Enable Custom File Types

To enable users to submit custom file types, follow these steps:

Step 1

Visit the USP Pro settings ▸ Uploads Tab ▸ “Allowed File Types”. There you must add the allowed file types to the list, separated by commas. For example, to allow PDF and DOC files, we would add the following to the list: pdf, doc.

Step 2

Add the following shortcode to your USP Form. Feel free to customize the attributes to suit your desired configuration.

[usp_files class="" placeholder="" label="" required="" max="" link="" multiple="true" method="select" key="" types=""]
Step 3

After adding the shortcode to your form, visit the form on the front-end and try submitting a test post. Once the post is submitted, view it in the WP Admin Area, and look for the attached custom field: usp-file-1 (where 1 equals the file number).

Step 4

Once the custom field is available, it may be displayed using any suitable WordPress or USP template tag (there are many available!). One example is to add the following tag to the WordPress Loop in, say, your theme’s single.php template:

<?php echo usp_get_meta(false, 'usp-file-1'); ?>

Also here you would change usp-file-1 to the Name of the desired custom field (it will be the same for all posts that are submitted via that specific form). Once this tag is added to your theme loop, it will display the value of the custom field, which would look like this for a submitted PDF file:

http://example.com/wp-content/uploads/example.pdf

So then you can use this to create a link to the PDF (or whichever file type you are using) for download:

<a href="http://example.com/wp-content/uploads/example.pdf">Download</a>

And of course you can customize the markup and text to suit your specific goals.

Update! For an easy way to display custom fields on the front-end, check out the free Helper addon for USP Pro.

Resources & References