Banner for Advanced Code Recipe Tutorial for Paid Memberships Pro

Out of the box, Paid Memberships Pro will give you many options to lock down your WordPress posts and pages. You made need to restrict access to protected files as well. PMPro comes bundled with a script to lock down media and file attachments uploaded to protected posts; you just need to add constant definition and a couple lines to your .htaccess file to direct traffic to those files to the bundled script.

You can also lock down non-WordPress files and entire directories of files using Paid Memberships Pro. The basic method is the same: (1) add a mod_rewrite rule to your .htaccess file to direct traffic to the directory and file to a special script, and (2) run a script to check for membership before serving the file.

Below is sample code for your the rewrite rule and the script to serve the file along with a description of how it works.

This content requires a premium membership plan.