After that we are creating a variable called whitelist. This variable will be used to define an array with all the extensions that are available for download. We are also applying a filter which can be used to extend this array or not. How to use WordPress filter can be learned here. After that we are checking if the file is allowed and also to check if the file is not a php file just to be sure.
If those checks pass we are setting the content type for the headers we will send from the server. We are also applying a filter to this variable and we are also passing an additional parameter which is the extension.
By using this filter together with the filter before we can extend this functionality and enable other files for download. When everything is set we are sending to our user different headers with the file for download. Like this: Like Loading All Posts Website.
Share this: ManageWP. After that this code worked as treat, so, many thanks! Igor Benic May 24, at am. Thank you very much for that! I saw the errors in the code and corrected them. Nathan Hawkes September 26, at am. Have you found that your customers find this option easy to use? Nice post! Your email address will not be published. This site uses Akismet to reduce spam. Learn how your comment data is processed. Share via: Facebook Twitter LinkedIn.
Related Posts. Leave a Comment Cancel Reply Your email address will not be published. Copy link. Copy Copied. Powered by Social Snap. WordPress has become one of the most popular platforms for users to create websites. One of the ways you can do that is by backing up your site, including the media files.
Other than security reasons, there will also be a time when you might need to transfer images between websites. The safest way you can download your media library is by using the hosting control panel. Scroll down to the Files section and click on the File Manager. You can use them to share images, documents, guides, infographics, templates, and other useful resources with your visitors.
If you have any doubt about the process above, reach out to us in the comments below. Check the video below:. Hey Fardeen, the video at the end of the blog may help. Nice tutorial! You can also use WP File Downloads that has a dashboard that will helps you with everything and also allows you to connect it with cloud services like Google Drive in order to serve files directly from there!
Still relevant in so I have written a small plugin that enables secure and temporary downloads in Wordpress:. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 9 years, 1 month ago. Active 1 year, 1 month ago. Viewed 6k times. I am using Wordpress and Easy Digital Download plugin to sell digital files. I have the following how-to questions: How to avoid a user to see or to use direct download link?
0コメント