Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've got User Role Editor plugin installed and i want to add a capability for download files.

I've got some downloads in a custom post type called 'products'. I want only people who are logged in to be able to download or view these files. If a user isn't logged in they get redirected to a login/registration page, then they log in and get redirected back to the product page.

User role editor has a capability for upload files so was wondering if it can be used to download files as well.

Or should i use some other plugin or something to get this?

Thanks

share|improve this question
    
Can any logged in user download these files? Or only certain users? –  Kevin Langley Jr. Nov 10 '11 at 13:57
    
Any logged in user. –  Corbula Nov 10 '11 at 14:23

1 Answer 1

up vote 1 down vote accepted

Since you're just checking to see if they are a logged in use, you can just use the is_user_logged_in() function to check if they are logged in and if so, display the download link, if not, don't display the download link.

share|improve this answer
    
Thanks, but is it possible to display the download link even if the user isn't logged in? because if a user isn't logged in and it doesn't show the download links they will just get a blank section. I want the links to show for everybody but only users that are logged in can actually view or download the files. –  Corbula Nov 10 '11 at 15:15
    
In that case, you have a couple of options, either you can create a download script that will check if the user is logged in and if so, allow the download if not, block it. Or, you can just use another plugin. I found this plugin here that I think would fit your needs. Check it out and let me know. wordpress.org/extend/plugins/download-monitor –  Kevin Langley Jr. Nov 10 '11 at 16:22
    
I've looked at the plugin and i think it will be good for a different section of the site which will be a members only download section. However it's only good for downloads uploaded with that plugin. It won't work for my needs because the files i want this to work on are uploaded via a custom field on my custom post type. –  Corbula Nov 10 '11 at 17:54
    
I'm using download monitor to get pretty much what i needed. –  Corbula Nov 24 '11 at 15:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.