Skip to main content
Easy Digital Downloads Blog
WordPress Tutorials, Tips, and Resources to Help Grow Your Business
How to Limit File Downloads to Logged in Users in WordPress

Do you want to learn how to limit file downloads to logged in users in WordPress? Offering downloads to logged in users only can help prevent unauthorized file sharing. It’s a great way to help get subscribers for your online store or membership site.

In this article, we’ll show you how to restrict downloads using Easy Digital Downloads!

There are two ways you can approach this depending on which version of EDD you’re using. With EDD 3.1 or higher, the option to restrict file downloads to logged in users comes built-in. But if you’re using an older version, you’ll need to either update the EDD plugin or manually insert code via another plugin.

We’ll walk you through both methods:

Step 1: Download and Install Easy Digital Downloads
Step 2: Add the File You Want to Restrict Access To
Step 3: Enable the Require Login Setting
Alternative Method: Insert Force Login Code Snippet

Step 1: Download and Install Easy Digital Downloads

If you haven’t already, the first step is to download and install our Easy Digital Downloads plugin. This is a powerful tool for selling digital downloads. You can use it to offer a wide range of products, including unlimited files, eBooks, PDFs, and much more:

The WordPress and Easy Digital Downloads logos.

It’s trusted by more than 50,000 websites. Also, unlike other eCommerce plugins, EDD focuses specifically on helping you sell digital products. There are multiple plans to choose from so you can easily find the one that makes the most sense for your needs.

Once you select your EDD pass, you can download the plugin and upload it to your WordPress website. If you’re unfamiliar with this process, follow this simple step-by-step guide on installing plugins.

After uploading it to your site, click on Install Now, then Activate. This will add a Downloads item to your dashboard menu.

For more guidance on setting up EDD, you can refer to this guide: How To Easily Sell Digital Downloads.

If you already have EDD installed, make sure you’re using the latest version. If you want to update or upgrade your EDD, you can do so from the WordPress Plugins screen.

Step 2: Add the File You Want to Restrict Access To

Once you have EDD set up, you can start creating and uploading your digital products. If you haven’t already, now is a good time to upload the downloadable file to your WordPress site.

You can do this by going to Downloads » Add New:

Adding a new download using Easy Digital Downloads.

You can enter a file title, as well as a description. We’ll use an SEO eBook as an example:

A title and description for an eBook download.

To the right of the screen, you can also assign it a category, add a featured image, and more:

The Categories section of an EDD Download.

Next, you can set a price for your download by navigating to the Download Prices box located under the editor:

The Download Prices section of the EDD plugin.

There are a ton of features and settings you can apply to your downloadable product(s). We won’t get into all of them in this post. But you can refer to how to successfully launch your digital product to get started.

Step 3: Enable the Require Login to Download Setting

As we mentioned, if you’re using EDD 3.1 or later, the option to require users to log in before downloading files comes built into the plugin’s core settings. We always recommend upgrading to and using the latest version.

Once you have your downloadable file added, you can configure the settings to limit access. Navigate to Downloads » Settings » Misc » File Downloads. Next, select the Require Login setting:

The EDD option to Require Login for users to download files in WordPress.

With this enabled, all downloadable files will require users to log into your site first. When you’re done, click on the Save Changes button at the bottom of the screen. That’s it!

Alternative Method: Insert Force Login Code Snippet

If you haven’t upgraded to EDD version 3.1 or higher yet, there’s an alternative method that you can use to limit file downloads. It requires you to insert a force login code snippet to your site.

To make this quick and easy, you can use the WPCode plugin:

The WPCode WordPress plugin banner.

Previously known as Insert Footers + Headers, this free tool is used by over 1 million websites. It’s reliable, easy to use, and lets you add code snippets to your site without editing your theme files. It integrates seamlessly with WordPress and can make adding custom code to your site simple, even if you’re a beginner.

To add it, you can go to Plugins » Add New, then search for “wpcode”. It will be the first option. Click Install Now:

Installing WPCode in WordPress.

Next, click on Activate. It will add a Code Snippets menu item to your dashboard.

Adding the Code to Your Site

Once you have the WPCode plugin set up, the next step is to add your code. To limit file downloads to logged in users in WordPress, you can add the following:

Snippet Name: Easy Digital Downloads - Force Login to Download
Description: Force users to be logged in to download purchased files through Easy Digital Downloads
Author: Easy Digital Downloads
Author URI:
Version: 2.0
function eddwp_force_login_for_download( $download_id, $email, $payment, $args ) {
	if ( ! is_user_logged_in() ) {

		$login_url = wp_login_url( trailingslashit( home_url() ) . '?' . $_SERVER['QUERY_STRING'] );

		$message = sprintf( 'You must be logged in to download files. Login here.', $login_url );

		wp_die( $message, 'Error' );
add_action( 'edd_process_verified_download', 'eddwp_force_login_for_download', 10, 4 ); 

Copy the code. Next, return to WordPress and navigate to Code Snippets » Add Snippet:

The option to add a snippet with the Code Snippets WordPress plugin.

Hover over the Add Your Custom Code (New Snippet) option and select Use snippet:

The option to add a custom code snippet with the Code Snippets plugin.

After you add a title, in the Code Type drop-down menu, select PHP Snippet. Next, in the Code Preview box, paste the code you just copied:

The code that lets you limit file downloads to logged-in users in WordPress.

At the top, select the Inactive option to change it to Active then click Save Snippet:

The option to save a code snippet in the Code Snippets plugin.

Now when your users attempt to download a file, they’ll be asked to log into your site (if they haven’t already).

Conclusion: Limiting File Downloads to Logged in Users

Now you know how to limit file downloads to logged in users in WordPress. To add more content restrictions on your site, you can check out 9 expert ways to protect digital products (pros and cons).

Are you ready to start limiting file downloads on your site to only users logged into WordPress? Get our Easy Digital Downloads plugin to make doing so effortless!

Be sure to subscribe to our newsletter or follow us on Facebook and Twitter to get our latest resources for digital creators.

Using WordPress and want to get Easy Digital Downloads for free?

Enter the URL to your WordPress website to install.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. We only recommend products that we believe will add value to our readers.


  1. Casey Cavanagh

    Hello there. Great first post Casey! I’m excited to see all the cool things people can do with WP Code. It will be interesting to see how WP Code and EDD can work together like this.

    Best of luck working on the EDD blog. Find me on LinkedIn (look for thisisjoewells) if I can ever help with a question…

    1. Casey Cavanagh

Leave a Reply

Your email address will not be published. Required fields are marked *