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 trialshahardekel
20,306 PointsHow 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
Zac Gordon
Treehouse Guest TeacherAh, gotcha. Maybe something like this: https://wordpress.org/plugins/media-vault/?
Rich Bagley
25,869 PointsHi,
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
Treehouse Guest TeacherJust wrap the link in conditional tags that check if someone is logged in.
http://codex.wordpress.org/Function_Reference/is_user_logged_in
shahardekel
20,306 PointsHi Zac,
while this will work, visitors who get the link will still be able to download the file without a user in my site.
shahardekel
20,306 Pointsshahardekel
20,306 PointsLooks good. I'll give it a go and let you know how it works.
shahardekel
20,306 Pointsshahardekel
20,306 PointsSweet, 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.
Zac Gordon
Treehouse Guest TeacherZac Gordon
Treehouse Guest TeacherOh great!