Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

shahardekel
shahardekel
20,306 Points

How to enable file downloads in wordpress only for logged in users?

Hi,

I'd like to upload a specific file to my wordpress site. I only want users with an existing wordpress account to be able to download it. The file is going to be free for download so I don't need a payment gateway or anything like that.

I prefer an easy solution like a good and simple plugin that someone knows of.

Any suggestions?

3 Answers

shahardekel
shahardekel
20,306 Points

Looks good. I'll give it a go and let you know how it works.

shahardekel
shahardekel
20,306 Points

Sweet, that plugin works great! it adds a 'secured' checkmark to the wordpress media upload page, and if checked, it only allows logged-in users to download that file. Users who are not logged in are sent to the login page instead to the file download page.

Hi,

Please note that I haven't used this before but it may do what you need:

https://wordpress.org/plugins/download-manager/

Thanks

-Rich

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Just wrap the link in conditional tags that check if someone is logged in.

http://codex.wordpress.org/Function_Reference/is_user_logged_in

shahardekel
shahardekel
20,306 Points

Hi Zac,

while this will work, visitors who get the link will still be able to download the file without a user in my site.