0

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? – Mayeenul Islam Dec 2 '14 at 14:10
  • Sorry. Only the logged-in users. – Neil Dec 2 '14 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 Dec 2 '14 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 Dec 2 '14 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 Dec 3 '14 at 15:45
1

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

https://aftabablog.wordpress.com/2017/02/17/how-to-make-your-uploads-in-wordpress-visible-only-for-logged-in-users/

0

Adding this snippet to function.php should do the trick

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

EDIT

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, privacy policy and cookie policy

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