How Do I Restrict WordPress File Access to Logged-In Users? To restrict WordPress file access to logged-in users, you need more than just membership plugins. WordPress stores uploaded files in publicly accessible folders by default. Anyone who knows the direct URL can download your member-only content, premium downloads, and course materials without logging in. This guide shows how to properly restrict WordPress file access using the Prevent Direct Access Gold plugin—with zero coding required.
🎥 Watch the Full Tutorial
See the complete setup process in action with our step-by-step video walkthrough: https://youtu.be/01hs40IOcgc
🚨 Why WordPress Files Are Publicly Accessible
WordPress saves all uploaded files to the /wp-content/uploads/ directory. This folder is publicly accessible by design, which means guests can bypass your login page entirely by accessing files through direct URLs.
Here’s what that means: If someone discovers or guesses your file URL—for example, yoursite.com/wp-content/uploads/2025/01/premium-ebook.pdf—they can download it immediately. No authentication required.
This vulnerability affects:
- Membership sites with premium content
- Online course platforms with lesson materials
- Digital product stores with downloadable files
- Client portals with confidential documents
Standard WordPress user roles and permissions don’t restrict direct file access. That’s where dedicated file protection becomes essential.
✅ The Solution: Block File Access for Non-Logged-In Users
To restrict WordPress file access to logged-in users, you need a plugin that intercepts file requests and verifies authentication before serving the file. The Prevent Direct Access Gold plugin blocks unauthorized access by redirecting non-logged-in visitors to a 404 error page instead of delivering the file.
When a guest tries to access a protected file through a direct URL, the plugin checks their login status. If they’re not authenticated, the download fails. Only logged-in users can access protected content.
No coding is required. The entire setup takes three steps.
⚙️ How to Set Up File Access Restrictions
Step 1: Install and Activate the Plugin
Install the Prevent Direct Access plugin from your WordPress dashboard. You’ll need both the Free version (base functionality) and the Gold version (logged-in user restrictions) activated.
Navigate to Plugins → Add New, search for “Prevent Direct Access,” install it, and click Activate. Then activate the Gold version to unlock advanced permission controls.
Step 2: Enable Auto-Protection for New Uploads
Go to the plugin settings in your WordPress sidebar. Click on Prevent Direct Access → Settings.
In the General tab, locate the option labeled “Auto-protect New File Uploads” and toggle it ON.
This setting automatically protects every file you upload from this point forward. You won’t need to manually configure protection for new content—the plugin handles it automatically.
Step 3: Configure File Access Permissions
Directly below the auto-protection toggle, find the “Set File Access Permission” dropdown menu.
Click the dropdown. You’ll see several options:
- Admin users
- The file’s author
- Logged-in users
Select “Logged-in users.”
This is the key setting. It blocks file access for anyone who isn’t authenticated on your WordPress site. Only users with active login sessions can download protected files.
Save your settings.
📁 How to Protect Existing Files
The auto-protection setting only applies to new uploads. To restrict WordPress file access for files already in your Media Library, follow these steps:
- Go to Media → Library in your WordPress dashboard
- Select the file you want to protect
- Click the “Protect” button
- Click “Configure File Protection”
- A popup window appears—locate “File Access Permission”
- Select “Logged-in users” from the dropdown
- Click “Save Changes”
Repeat this process for each existing file that requires protection.
💡 What Happens When Protection Is Active
Once file access restrictions are in place, here’s how the system works:
For logged-in users: Files download normally. Authenticated users can access protected content without any friction.
For guests and non-logged-in visitors: When someone tries to access a protected file URL, they’re redirected to a “page not found” (404) error instead of receiving the file. The download never initiates.
This prevents unauthorized distribution of your premium content while maintaining a seamless experience for legitimate users.
🔐 Why This Approach Works
Traditional WordPress permissions control who can upload, edit, or delete files through the admin dashboard. They don’t control who can download files through direct URLs.
By intercepting file requests at the server level, Prevent Direct Access enforces authentication before serving any protected file. This closes the security gap that standard WordPress permissions leave open.
The 404 redirect approach also prevents attackers from confirming whether a file exists at a given URL—adding an extra layer of security through obscurity.
📝 Quick Setup Summary
To restrict WordPress file access to logged-in users:
- Install and activate Prevent Direct Access (Free + Gold versions)
- Enable “Auto-protect New File Uploads” in plugin settings
- Set “File Access Permission” to “Logged-in users”
- For existing files: protect individually through Media Library
Your member-only content is now secured. Non-authenticated visitors cannot bypass your login to download protected files.