How to Protect Course Files in LifterLMS: PDFs, Video and Uploads

How LifterLMS media protection keeps PDFs, images, audio and video files away from people who are not enrolled, how to protect a file, what signed download URLs are for, and the server settings that decide whether it really works.

  • Add as a preferred source on Google
Illustration for “How to Protect Course Files in LifterLMS: PDFs, Video and Uploads”

Restricting a lesson does not restrict the files in it. On a default WordPress site, a PDF workbook attached to a members-only lesson lives at a public address in wp-content/uploads. Anyone with the link can download it, and links get shared.

LifterLMS can protect files so that only students enrolled in a chosen course or membership can open them. This guide explains how to protect files in LifterLMS, how the protection works, what the signed download URLs added in version 10.2 are for, and the server checks that decide whether your files are actually safe. It is written for course owners and the developers who look after their sites, and was checked against the LifterLMS 10.3 source.

What LifterLMS media protection covers

Media protection is part of the free core plugin. It works on files in your WordPress media library: PDFs, worksheets, slide decks, images, audio and video files you uploaded to your own server.

It does not cover files hosted elsewhere. Videos on Vimeo, Wistia, YouTube or a streaming service, and files in cloud storage such as Amazon S3, are protected (or not) by that service's own privacy settings. The LifterLMS protected media documentation makes the same point.

Some files are protected automatically. Files students upload as assignment submissions, with the Assignments add-on, and as answers to upload questions, a question type from the Advanced Quizzes add-on, are stored as protected files, so other students cannot open each other's work.

How protection works behind the scenes

When you protect a file, three things happen:

  1. The file moves into a protected folder under wp-content/uploads/lifterlms/, together with its resized image versions. LifterLMS writes an .htaccess file there that denies direct access on Apache, plus blank index files to stop folder listings.
  2. Its URL changes. WordPress now hands out a URL through your site's front end, such as https://example.com/?llms_media_id=123, instead of the file path.
  3. Every request is checked. Before sending the file, LifterLMS decides whether the current user may see it.

By default the file is served to:

  • Site administrators and users with the LMS Manager role.
  • The user who uploaded the file.
  • Students enrolled in the course or membership the file is protected for.
  • Users who can edit that course or membership, such as its instructors.

Everyone else gets a "File not found" response with a 404 status. Add-ons that protect their own files can add their own rules on top.

How to protect a file

From the block editor

  1. Add or select an Image, Video, Audio or File block that uses a file from your media library.
  2. Click the lock icon in the block toolbar, labelled Protect image, Protect video, Protect audio or Protect file.
  3. In the Select Course or Membership dialog, choose who may access it and confirm.

The block's URL is updated to the protected address automatically. The dialog also shows which course or membership currently protects the file.

From the Media Library

  1. Open the file in Media > Library.
  2. In the attachment details, find LifterLMS Media Protection: and select a course or membership.
  3. Save. The file is moved to the protected folder.

Read the warning that appears: existing links to the file stop working once it moves. If you already inserted the file into lessons as a plain link, re-insert it afterwards so the content points to the protected URL. The cleanest workflow is to protect a file first and then use it in your lessons.

One-way, by design

There is no button to unprotect a file. You can change which course or membership protects it, but moving it back to a public location means re-uploading it as a new file. Decide what should be public, such as a free lead magnet, before you protect anything.

Check your web server: Apache, Nginx and hosts

This is where most protection quietly fails. The deny rule LifterLMS writes is an .htaccess file, which only Apache and compatible servers read.

  • Apache and LiteSpeed: the .htaccess rule blocks direct access automatically.
  • Nginx: .htaccess files are ignored. Without a server rule that blocks /wp-content/uploads/lifterlms/, the original file path may still be reachable by anyone who knows it. Ask your host or developer to add a deny rule for that folder, and an internal location if you use X-Accel-Redirect.
  • Managed hosts: some hosts run Nginx in front of Apache or have their own rules. LifterLMS detects WP Engine and serves files through PHP there.

Test it. Find the real path of a protected file (it is under wp-content/uploads/lifterlms/ plus the year and month folders), open it in a private browser window while logged out, and confirm you get a 403 or 404. Then open the protected URL as an enrolled test student and as a non-enrolled one. Do this after every server move.

How files are delivered

Where the server supports it, LifterLMS hands delivery back to the web server with an X-Sendfile header (Apache with mod_xsendfile, lighttpd, Cherokee) or X-Accel-Redirect (Nginx), which is fast. Otherwise PHP reads the file and streams it, which ties up a PHP worker for every download. Developers can change the method with the llms_media_serve_method filter.

Two practical consequences for video: protected files are served without HTTP range request support, so seeking in a large video can be poor, and streaming long videos through PHP is heavy on the server. For video lessons, a proper video host with domain restrictions is usually the better choice. See the best video hosting for LifterLMS for the options.

Signed download URLs for apps and integrations

A protected URL works only for a logged-in user with access. That is a problem when the request comes from somewhere without a WordPress login, such as a grading tool, a mobile app or a reporting system that downloads assignment files.

LifterLMS 10.2 added time-limited signed URLs for exactly this. A signed URL carries an expiry time and a token generated from your site's secret keys. Anyone holding it can download that one file until it expires, after which it stops working. The REST API now includes a download_url field with a signed link for files in assignment submissions and quiz attempts, so integrations can fetch them; see our introduction to the LifterLMS REST API and webhooks.

Links last one hour by default. The llms_media_signed_url_ttl filter changes that. Developers can also create signed links themselves, after doing their own permission check:

<?php
/**
 * Return a 15-minute download link for a protected file, or an empty string.
 * Only call this after you have confirmed the requester may have the file.
 */
function llmsx_temporary_file_link( $media_id ) {
	$protector = new LLMS_Media_Protector();

	if ( ! $protector->is_media_protected( $media_id ) ) {
		return '';
	}

	return $protector->get_signed_url( $media_id, 15 * MINUTE_IN_SECONDS );
}

Treat signed URLs like passwords with an expiry date. Do not put them in public pages or long-lived emails, and keep the lifetime as short as the use case allows.

The Content Protection setting is something else

Under LifterLMS > Settings > General there is a Content Protection checkbox described as preventing users from copying website content and downloading images. It adds browser-side copy and right-click blocking for users without Unrestricted Preview Access.

It is a useful deterrent against casual copying, but it is not file protection. Anyone determined can read a page's source or use developer tools. Use it alongside media protection, not instead of it. For other anti-sharing measures, see how to stop account sharing in LifterLMS.

Common mistakes

  • Protecting the lesson but not the file. Lesson restrictions do not apply to files in wp-content/uploads.
  • Assuming Nginx honours .htaccess. It does not. Test the direct path.
  • Protecting files after linking them. Old links break. Protect first, then insert.
  • Serving large videos as protected files. Use a video host with privacy controls.
  • Caching protected URLs. Exclude ?llms_media_id= requests from page caching and CDN caching rules so one student's access is not cached for everyone.
  • Forgetting downloads leave your control. Once a student has downloaded a PDF, protection cannot stop them sharing the file itself. Add the student's name or licence terms to high-value documents if that matters.

Frequently asked questions

Does LifterLMS protect Vimeo or YouTube videos?

No. Media protection applies to files in your own media library. Use the video host's privacy and domain-restriction settings for hosted videos.

Can I protect one file for several courses?

The core setting links a file to one course or membership. If several courses need the same file, protect it for a membership that includes them, or ask a developer to add an authorization rule.

Why do enrolled students get "File not found"?

The file is protected for a different course or membership than the one they are enrolled in, they are logged out, or a cache served a response meant for someone else. Check the protection in the Media Library first.

Are student assignment uploads private?

Yes. Files submitted through the Assignments add-on and through Advanced Quizzes upload questions are stored as protected files.

What to do next

List the files that are worth protecting, usually workbooks, templates and downloadable resources rather than every image, then protect them for the right course or membership and run the direct-path test from a private window. If you are on Nginx, get the server rule added before you rely on any of it.

If you need protection for files in S3, rules across several products, or watermarked downloads, our LifterLMS customization team can build it. For a full review of how exposed your course content is, our LifterLMS support plans include security checks. Get in touch and tell us what you need to keep private.

Add LifterLMS Expert to your preferred sources

Add lifterlmsexpert.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.

  • Add as a preferred source on Google
Free consultation

Prefer expert help over DIY?

Skip the trial and error. Get specialist LifterLMS help and ship faster.

Talk to a LifterLMS Expert Explore our services

Replies within one business day