When you upload a file to your website, the item you’ve uploaded is, by default, public, at whatever URL your site give it – usually something like sitename.com/[various paths]/imagename.jpg (or /document-name.pdf, etc). And for a photo, for example, to be visible on a page where you want to show it, that image needs to stay public.
But sometimes you want to upload something – often documents – that you don’t want to be public, but want to be available only to logged-in users of your site. Some web site software offers an option for this out of the box (e.g. Drupal), but WordPress does not. Instead, you have to use a plugin (or custom code) to do the work.
In the WordPress world, many of the plugins that can do this are focused on “membership sites,” or sites where you want to keep certain content available only to site members. Many such sites are commercial, charge a fee for membership, and are looking for many functions in addition to keeping files private. Therefore, many plugins offer a great many functions and options that aren’t necessary for the primary task of keeping files private.
In searching for the simplest, most reliable plugin for this job, I found two candidates: one, Media Vault, has a wonderfully simple user interface, but hasn’t been updated in a long time, isn’t used by many sites at all, and it’s not clear it works reliably. The other, Download Monitor, is still quite “heavy,” and aimed at users who want to do more than simply keep files private, but it seems to offer the simplest and most reliable option available.
Use Download Monitor to add a new private file
- Find the new item in the admin menu labeled Downloads, and choose Add New. You’ll get a screen that’s almost identical to a new Post or Page, but that adds some boxes at the bottom. (That is, it has a big empty box for entering text, just like a post or page, but you’ll usually want to leave that empty.)
- Fill in the “title” box with the title you want your file to have
- Skip the large main text entry box and find the “+ Add file” button in the next box.
- Click that, and in the new area that appears, find the Upload file (NOT the “Browse for file” button – it’s very confusing), which takes you to the usual Media Library interface where you can upload a file (or find one already in the Media Library). Once you’ve uploaded or selected your file, click the “insert URL into box” to add the file’s URL into the “File URLs” box above. (The plugin allows you to add multiple copies, or versions, of a file, thus the complicated interface; for more details on what all the options are, see https://www.download-monitor.com/kb/adding-downloads/).
- *** In the sidebar on the right, find the “Members only” box and check that off. This is the key feature – it’s what keeps the file private. (For more on the other boxes, see: https://www.download-monitor.com/kb/download-options/)
- Click the standard blue “Publish” button.
- In the box above, find and copy the “shortcode” that’s been created for inserting your file.
- Open the page or post where you want to add the private file, and paste the shortcode where you want the file to appear. When the page is viewed, you’ll see the title you’ve given the document, which will be linked to the document itself.
To use it for an existing (public) file you want to make private:
To use it for an existing file that you want to add protection to, you basically follow the steps above, though obviously you’ll replace the existing reference to the file, being sure to remove the original reference. But there’s another important step: once you have the private file up and working, be sure to DELETE THE ORIGINAL, PUBLIC version of the file from the Media Library!!