I am learning php but i am still quite a noob so please excuse my limitations.
I have a html file that is linked to many PDF files inside a folder called "Clients"
I have placed this folder inside "wp-content/uploads/"
The html page opens as inside the wordpress page.
When a user logs in, it opens the wordpress page that has the html page displaying the links. Clicking on the links opens the PDF file in the same window without going to another page.
This is a multisite wordpress installation and I want to protect the direct URL access to the files inside the "Clients" folder if the user is not logged in.
for example: "https://mywebsite/wp-content/uploads/clients/001.pdf" should not be accessible when the user is not logged in.
I just want to protect direct url access of any files within clients folder.
I have tried using Hakre's solution from
How to Protect Uploads, if User is not Logged In?
How to protect uploads in multisite if user is not logged in?
Hakre's solution gives me a prompt to download the files. It also displays blank pages when the user is logged in
I want something as simple as if someone tried to access the PDF files directly via the url it should check if the user is logged in and open the file in the browser (not prompt for download) or else redirect to the home page url.
Could someone please help us out here.