Protect LearnDash Course Files

Goal: only enrolled students can open your course PDFs

LearnDash runs the course (enrollment, lessons, quizzes). Media Guard protects the actual files inside it — the PDFs, workbooks, audio, video, ZIP downloads. The two work side-by-side: LearnDash decides who’s a student, Media Guard makes sure only students can open the files.

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

  • LearnDash is installed and you have at least one course set up.
  • Media Guard is installed and activated.
  • For per-course access lists you’ll want Media Guard Pro (so you can use Groups). The Free version works fine if all students share the same role.

The recommended setup

The cleanest pattern is: one Media Guard Group per course, students get added to the group when they enroll.

Step 1 — Create a Group for your course (Pro)

In Media Guard → File Manager, upload your course files (drag and drop them onto the upload zone). Then check the boxes next to those files, open the Assign to Group… dropdown, and create or choose a group named after your course — for example, course-a-students.

On the Free version, skip this step and use a WordPress role instead (see “Free version path” below).

Step 2 — Embed the file in your LearnDash lesson

Edit the LearnDash lesson where the file should appear. Paste the Media Guard shortcode into the lesson content:

[mediaguard file="course-a-week-1.pdf" groups="course-a-students"]

Want the PDF to display inline (embedded viewer) instead of as a download link?

[mediaguard file="course-a-week-1.pdf" groups="course-a-students" embed="yes"]

Step 3 — Connect enrollment to the Group

This is the only piece that needs a tiny bit of glue: when a student enrolls in a LearnDash course, you need to add them to the matching Media Guard Group. Two easy ways to do it without writing code:

  • Uncanny Automator — a free/paid plugin. Trigger: “User is enrolled in a course.” Action: “Add user to Media Guard Group.”
  • A membership plugin that assigns a WordPress role when a course is purchased. Then you can use roles instead of groups.

Free version path (no Groups)

If you don’t have Pro, use a WordPress role instead. Create a role like “Student” (with the Members plugin), assign it on enrollment, then:

[mediaguard file="course-a-week-1.pdf" roles="student"]

The trade-off: every student gets the same role, so you can’t easily restrict per course. That’s exactly what Groups are for.

Test it

  1. Open an Incognito window and try the direct file URL — you should be denied.
  2. Log in as a test student who is not enrolled — still denied.
  3. Enroll the test student in the course — they should now see the file.

FAQ

Can I embed a viewer right inside a LearnDash lesson? Yes — add embed="yes" to the shortcode and the PDF renders inline with print/download blocking applied (Pro feature for blocking).

Do I lose access when a student finishes the course? Only if you set that up in your enrollment automation. By default, group membership stays until you remove it.

Can a file be in more than one course? Yes. Assign the file to multiple Groups, and list them in the shortcode separated by commas: groups="course-a,course-b".

Related Pro features

Looking to scale this across a real LearnDash course catalog?

  • Pro Features Tour — See what Pro adds on top of the LearnDash integration.
  • Groups & Users — Map LearnDash groups to Media Guard groups for bulk file access.
  • Access Log — Audit which student downloaded which lesson file.

See Pro & Agency pricing →