WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a wordpress site that I would like to secure specific files in the uploads directory, so that they can only be accessed by logged in users. The files either have the word "oneperson" or "twopeople" in the filename, and are of the format "zip" or "pdf".

How do I do this?

share|improve this question
up vote 0 down vote accepted

This is not quite trivial, because natively WP is engineered to completely ignore requests to existing files. So WP doesn't pay attention to files and .htaccess doesn't have access to WP's logged in information.

If you look for prior art (in plugins for selling digital files for example) this isn't easily (at all?) doable with direct links. Typically special download links are created and processed by plugins to serve files while masking it's true name/location (which should be restricted from direct access or not in web accessible folder at all).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.