• Hello,

    I would like to ask about a plugin that allows me to upload tests results to wordpress as PDF files and add a code for every test. So every user having the code can only download the test result.

    How can I do this? I read about the Simple Download Manager and the Password Protect thing, but this will create a page for every download while I need to have one page where the user can enter the code and the corresponding pdf (linked to this code) is downloaded.

    I hope I made myself clear.
    Thank you so much!
    Best Regards,
    Layale.

    • This topic was modified 8 years, 1 month ago by layale.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    There are a slew of download managers available. If none of them work the way you want, it shouldn’t take too much custom work to alter one of them to work for you. For example, one of those download pages for a specific download could be altered into a template that dynamically generates a page based on the file to be downloaded.

    Or perhaps instead of retrieving a specific file, some script takes the password and enters a lookup table to determine what file to retrieve. For that matter, it wouldn’t take much coding to make a page template that does this. Once the source file is determined, the download response is started with something like

    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"{$yourfilename}\"");
    readfile($full-path-to-your-file.$filename);

    The header calls must be nearly the first thing on the page template, before any output.

    I realize you are looking for a plugin solution and are not wishing to get into custom code, but when you have very specific need, custom code is often the right solution. When you do not need anything fancy, hiring someone to knock out some custom code needn’t be too expensive.

    Thread Starter layale

    (@layale)

    Hello,

    Thank you so much for this. I really appreciate it. Well I am a developer but new to wordpress and php. I am using an online version of wordpress from the hosting company. So I don’t understand well what you are proposing. If there is any link or tutorial that will put me on track I will highly appreciate it. I am ready to learn and do the custom code but I dont know from where to start. I am also ready to pay for a plug in if it can do the work. The problem is that I want it to be easy for an employee who will be uploading the pdfs and give a code for every file. Usually this guy won’t be IT and will not be able to go through creating a page and adding security… Any more hints that will put me on the right track?

    Thank you again,
    Regards.

    Moderator bcworkz

    (@bcworkz)

    Well, welcome to the WordPress community then!

    The online version provided by your host isn’t much different than the downloaded version. Your host is simply making the installation a one click affair. The downloaded version is nearly a one click affair as well, the main difference is you need to upload the files to your server. Hosts will often make some modifications to their one-click version in an effort to make things easier for themselves. On occasion that can cause problems, but usually it’s fine. Either way, you are typically still fully responsible for the installation on your server space. The amount of support from hosts is variable, trending towards none.

    Some very general resources you’ll find useful sooner or later:
    The Codex
    WP Developer Resources
    PHP Reference

    You will likely be needing at least one custom page template. These belong in a child theme. You do not want to modify your primary theme’s files because your changes will be lost when the theme is updated. In fact, the first rule in WP is never modify anything subject to updates: WP core, themes, plugins. Create your own theme, child theme, or plugin to contain your custom work.

    If you do find the need to hire knowledgeable help, please do not solicit paid help here in the forums. It’s against our guidelines and will cause your inquiry to be closed. Unfortunately, we’ve had…uh… let’s say unsavory characters trolling for work here. Never accept any offers for paid help here. If you need assistance finding knowledgeable help, try jobs.wordpress.net or jetpack.pro .

    Plugins can be a good resource if you get stuck on how something is accomplished. You don’t have to use the plugin, rather examine its source code to see how others have done a similar task. The beauty of open source! If you do use any code verbatim, be sure to credit the source.

    A good part of modifying how WP works is through filter and action hooks. Study how these work until you fully understand what’s going on. It’ll be worth the effort.

    Most importantly IMO, enjoy the process. If you don’t get some enjoyment out of coding, you are better off hiring someone. Life’s too short 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding a code to uploaded pdf documents’ is closed to new replies.