Protect Your First PDF
Goal: protect a PDF, share it with logged-in users, test that it works
This is the fastest possible walkthrough. If you can copy and paste, you can do this. You do not need any code, and you do not need the Pro version to follow along.
The bouncer model. Think of Media Guard as a friendly bouncer outside a private club. Your files live in a locked back room only the bouncer can open. When someone asks for a file, the bouncer checks their ID (are they logged in? do they have the right pass?) before opening the door.
Before you start
- You’re logged in to your WordPress dashboard as an Administrator.
- The Media Guard plugin is installed and activated. You should see a Media Guard item in the left admin menu (it has a small shield icon).
- You have a PDF on your computer ready to test with.
Step 1 — Upload the PDF to Media Guard’s secret vault
In your WordPress dashboard, click Media Guard → File Manager in the left menu.
You’ll see a large dashed box that says “Drag & drop files here.” Drag your PDF onto that box (or click it to pick a file).
The file uploads into Media Guard’s protected folder. This is a special folder on your server that is blocked from the public web — not the normal WordPress Media Library. Anyone trying the file’s URL directly will be denied.
Important: do not use the regular Media menu for files you want to protect. Anything uploaded there is public.
Step 2 — Copy the file’s name
After upload, your PDF appears in the file list. Note the exact filename in the File column (for example, my-private-guide.pdf). You’ll paste this name into the shortcode in the next step.
Step 3 — Put a Media Guard shortcode on a page
Go to Pages → Add New and give the page a title like “My Private Library”.
In the content area, paste this exact code (replace the filename with yours):
[mediaguard file="my-private-guide.pdf" roles="subscriber"]
That’s it. Click Publish.
What does that line mean?
file="my-private-guide.pdf"— which file from the vault to share.roles="subscriber"— only WordPress users with the Subscriber role can open it. (Subscriber is just the default name for a regular logged-in user.)
Want to embed the PDF directly on the page instead of a click-to-download link? Add embed="yes":
[mediaguard file="my-private-guide.pdf" roles="subscriber" embed="yes"]
Step 4 — Test it the right way
Here’s the catch most people miss: Administrators always bypass protection. The file will always open for you. To see what a normal visitor sees, you need to pretend you’re not the boss.
- Open a Private or Incognito window in your browser.
- Visit your new “My Private Library” page.
- Try to open the file. You should get a “Please log in to view this content” message. That means it’s working.
- Log in (in the private window) as a Subscriber user. Now the file should load.
Common gotchas
- “It still opens without logging in.” You’re testing as an admin in your main browser. Use an incognito window.
- “The shortcode shows up as text instead of working.” Make sure you pasted it into the page editor’s content area, not into a Code block. WordPress needs to process the shortcode, not display it as code.
- “It says ‘missing file attribute’.” The filename in the shortcode must exactly match what’s in the File Manager — including capital letters and the
.pdfat the end.
What’s next?
You just used the simplest access model: Roles. There are two other ways Media Guard can decide who gets in — Groups (Pro) and WooCommerce purchases. The next page explains the differences and when to use each.
Next: How Media Guard Access Works →
Related Pro features
Now that your first PDF is protected, here’s what Pro can do for the rest.
- Pro Features Tour — A 5-minute walkthrough of every Pro screen.
- Install & Activate Pro — Already bought Pro? Activate your license in 60 seconds.
- Groups & Users — Protect 100 files for 50 users without 5,000 clicks.