I want to restrict the uploads and only be visible to logged-in users. But the PDF's or images files always are visible and also to un-logged users. You can imagine that this WP would be completely private. Only for logged-in users.

Is there any way to fix that? Can be solved without .htaccess file?

In folder that I am using there is a .htaccess with the following: deny from all but don't works.

  • I'm afraid, can't get you correct: You want to upload PDFs, but don't want to show 'em to the logged out visitors, but the logged-in users only? Commented Dec 2, 2014 at 14:10
  • Sorry. Only the logged-in users.
    – Neil
    Commented Dec 2, 2014 at 14:22
  • And you want this to only apply to PDFs and not other files e.g. images? What you ask for is difficult, and may require server specific knowledge depending on the solution, with a performance cost ( and is unlikely to be foolproof either ). Are you sure WordPress is the right choice if you're wanting such levels of security? As a side note, htaccess questions are usua lly ( though not always ) offtopic here, as it's a server technology, not a WordPress technology
    – Tom J Nowell
    Commented Dec 2, 2014 at 14:27
  • All uploads will be the best option. Right. I started with Wordpress and now is difficult to change. Which is the best CMS for do that? Is possible that is there another possibility without .htaccess?
    – Neil
    Commented Dec 2, 2014 at 17:31
  • I think that I will find a solution but one question? Wordpress allow to download very large files? Or it depends of another thing?
    – Neil
    Commented Dec 3, 2014 at 15:45

2 Answers 2


Please go through this blog written by me. Here you will get your answer for your question.



Adding this snippet to function.php should do the trick

  function restrict_mime($mimes) { 
      $mimes = array(
          'pdf' => 'application/pdf',
      return $mimes;


Sorry, didn't read carefully, I see you need to be able to upload PDFs, but just hide it from guest users. It will need different approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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