Protecting images and files in private knowledge bases
When a knowledge base is restricted, PinkDocs protects more than the text. Screenshots, PDFs and every other file you add to its docs can only be opened by people who are allowed to read those docs. Anyone else gets "not found", even with the file's direct link.
How file protection works
A file belongs to the doc it was uploaded to. When that doc is in a restricted knowledge base, PinkDocs:
- Moves the file, and every resized copy WordPress makes of an image, into a private uploads folder with an unguessable name.
- Serves it only through WordPress, after checking that the visitor may read the doc. Everyone else gets "not found".
- Leaves it out of the Media Library REST API, attachment pages and the media picker for anyone who can't read the doc.
- Updates the image addresses in your docs automatically, so nothing breaks for readers who do have access.
This works the same however the file arrives:
| Added through | Protected |
|---|---|
| Block editor (image, file and gallery blocks) | Yes |
| Media Library, attached to the doc | Yes |
AI tools over MCP (upload_media) | Yes |
| Git Sync (images in your repository) | Yes |
| Import and AI featured images | Yes |
Give access to specific people
Besides All logged-in users and Specific user roles, a knowledge base can be limited to named people. This is the simplest way to give each client or project partner their own private knowledge base, without creating a WordPress role for each one.
Edit the knowledge base
Go to PinkDocs → Knowledge Bases and click Edit on the knowledge base.
Turn on Restrict Access
Switch on Restrict Access under Access Restrictions.
Choose Specific people
Select Specific people, then search by name or email and click each person to add them. Click × on a name to remove it.
Save your changes
Click Save Changes. Only the people you added can read the knowledge base and open its files.
Editors and administrators can still manage every knowledge base's docs and files in wp-admin.
Changing a knowledge base from private to public
PinkDocs moves the files for you whenever access changes:
- Restricted → public: files move back to normal uploads and become public files again. Old protected links redirect to the public file.
- Public → restricted: files move into the private folder straight away, and their old public addresses stop working.
- Moving a doc to another knowledge base moves its files with it.
Large knowledge bases are finished in the background within a few minutes.
Server setup
Check Tools → Site Health for PinkDocs protected files. It tests whether your server refuses direct requests to the private folder and, if it doesn't, shows the exact rule to add.
Usually nothing to do: PinkDocs adds the blocking rule to the private folder itself. Some hosts put nginx in front of Apache to serve images, which skips that rule, so confirm the result in Site Health.
nginx ignores the rule file in the folder, so add the one-line rule that Site Health shows you to your site's nginx configuration, then reload nginx. It looks like this, with your own folder name:
With the rule in place you can also let nginx deliver the files, which is faster for large PDFs. Add this to wp-config.php:
If your hosting company manages the server for you, send them the rule from Site Health and ask them to add it.
Uploading files with AI tools (MCP)
When an AI tool is connected to PinkDocs over MCP, it can add screenshots and PDFs with the upload_media tool:
- The AI tool creates or picks a doc.
- It uploads the file to that doc, either as file data or from a public web address.
- PinkDocs returns ready-made Markdown, and the AI tool adds it to the doc.
Because the file is attached to the doc, it gets exactly the same protection as one you upload yourself. The upload needs a connection with write access and a WordPress account that can upload files and edit that doc. PinkDocs checks the real file type, so a file that only pretends to be an image is refused.
Common questions
No. Protected files are only served after PinkDocs checks that the visitor may read the doc. Anyone else gets "not found", whether they're signed out or signed in without access.
No. Give each partner their own knowledge base limited to their people. Each partner can only open the docs and files of the knowledge bases they have access to.
After updating to 2.2.2, PinkDocs moves the files of docs in already-restricted knowledge bases into the private folder automatically, in the background.
Yes. Every size WordPress creates, and the original of large images, moves into the private folder together.
Public docs and files aren't affected. Protected files go through WordPress so it can check access, which adds a little work per file. On nginx you can hand delivery back to the server with x-accel-redirect.
