• Resolved nubian1

    (@nubian1)


    I am using the download codes plugin on https://www.djneaux.com/dev/tunes/ and I have been able to upload files to the upload folder and generate codes successfully. But, when I put in the code it takes me to the page which is supposed to have the download file. The page appears to have the file and even says what size the file is but when I click on the link it never downloads the file but takes me to https://www.djneaux.com.
    I have tried it with several files, I tried relocating the uploads folder, updating the permalink and deactivating and uninstalling the plugin then reinstalling it and starting over again but nothing has worked. Please let me know how to fix this.

    Thank you

    https://www.ads-software.com/extend/plugins/wp-download-codes/

Viewing 12 replies - 1 through 12 (of 12 total)
  • I’ve been having the same problem. At first I thought the issue was complex ID’s/names for the downloads (something with spaces and symbols), and I tried changing the filename, ID name and labels to something simple – but it didn’t work.
    I’ve tried SO MANY things to try to get this error to stop happening, and the only thing I’ve come up with is this:
    https://i.imgur.com/Kw4Yt.jpg
    The first download was a test I did a while ago, and it worked fine (when I changed to simple labels etc), and you can see the code ID 251.
    The other few downloads have all failed, and send me to the main URL with some generated lease ID, and they all have a code ID of -1.
    Not sure what is causing WPDC to use a download code of -1 instead of the actual code ID’s but I think that’s the problem.

    After a bit of hacking around, I’ve found something that’s interesting, but I can’t quite make sense of it yet. In dc_template.php apx line 93:

    $html .= '<p>' . dc_msg( 'code_valid' ) . '</p>';
    $html .= '<p><a>= 0 ? substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], '?' ) ) : $_SERVER['REQUEST_URI'] ) . '?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    If you change it to something like:

    $html .= '<p>' . dc_msg( 'code_valid' ) . '</p>';
    $html .= '<p><a href="https://hard-link-to-file">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    – It works fine. It defeats the purpose of the plugin as the link is now visible, but it indicates that the codes, number of downloads, etc are working OK.
    Now to find a solution…

    OK!
    After more mucking about, getting lost in a maelstrom of PHP voodoo I’ve managed to fix the problem. It has to do with having WordPress installed in a different directory than the root.
    SO, all I did was change dc_template.php line 95:

    $html .= '<p><a>= 0 ? substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], '?' ) ) : $_SERVER['REQUEST_URI'] )."/home/index.php" . '?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    The change being the addition of “/home/index.php” before the lease id.
    So if you update /home/ to wherever your wordpress is installed hopefully it will fix your problem too.

    Thread Starter nubian1

    (@nubian1)

    Thanks so much! Moving my WP files to the top level directory worked.

    WOW!! Thank you sooooo much! My DL code has been doing this for about a year, and I have a record out that nobody could download my codes for.. It used to work and then something happened, anyway with the advise above it now works!!! You are totally awesome!! Thank you!!

    https://www.mliotta.com

    I’m having this same issue, and can’t seem to get it to work. I have my wordpress installed in a directory called “wordpress”. I’ve tried to use your code here every which way I can and the best result I get is that it simply sits on the download page like it’s trying to do something but nothing happenS, just keeps sitting there in a busy state.

    Using the entire code you posted for line 95 gives me errors, looks a bit different than what I have, but I’ve arrived at this for line 95:

    $html .= '<p><a href="https://' . $_SERVER['HTTP_HOST'] . ( strpos( $_SERVER['REQUEST_URI'], '?' ) >= 0 ? substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], '?' ) ) : $_SERVER['REQUEST_URI'] ) . "/wordpress/index.php" . '?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

    Notice that I’ve indicated where my wordpress is located, but can’t seem to get it to work. BTW, I had the codes working fine when I initially installed this, so I’m not sure why they aren’t working now?

    Any and all suggestions would be greatly appreciated!

    url: https://www.patchworxmusic.com/wordpress/downloads/

    code for testing: BIGERYZ1S59

    THANKS!

    UPDATE: I’ve noticed that if I refresh the page (as it is just sitting thinking) that the download will start? I think I’m on the right track, and now I can tell it’s looking in the right direction, but not sure why it gets stuck? THANKS AGAIN SO MUCH!

    I’m having this problem too of my downloads redirecting to my home page, but I don’t understand b0gn0z‘s fix. I don’t know what “dc_template.php line 9″5 means and where I would find it to change “/home/index.php”. Can someone please explain?

    I previously had my folder containing the zip file in /public_html/blog/wp-content/uploads/

    I moved it up to /public_html/blog/wp-content/ and they’re still redirecting to the homepage.

    Is that what nubian1 meant by moving the WP files to the top level directory?

    So I moved my file to /public_html/blog/wp-content/ which is where I think it should be (but who knows since there’s apparently no developers to help out here?) and now under Manage My Releases it says “No files have been uploaded to the releases folder: /public_html/blog/wp-content/ You must do this first before adding a release!”

    But I did upload my release to the correct folder, so what can I do to make it recognize the files?

    Hi hollyrock,
    I think the moderator has all but given up here, so we’re on our own. I was able to resolve the issue I was having by adding an “external” class to the code, it’s a bit over my head, but something in the theme I’m using was interfering with the download. Here’s a communique from my web guy explaining how we resolved it on our end.

    Since the downloads links are also using short code, I was able to put a line of javascript on the downloads page that will add the “external” class to the download links. It worked great for the promo code download.

    Note that we added class="external" to the download links, and it solved the issue.

    I hope that helps, let me know how it comes out.

    – s

    I had the same problem, since my wp install is not in the root of the webserver. Instead of hard-coding the install path in the script, I just made a call to site_url(). This should make the script work in all cases. At least it does for me.

    I changed line 95 into: $html .= '<p><a href="'.site_url() . '/index.php?lease=' . $download_lease_id . '">' . ( $release->artist ? $release->artist . ' - ' : '' ) . $release->title . '</a> ' . format_bytes( filesize( dc_file_location() . $release->filename ) ) . '</p>';

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: WP Download Codes] file link redirects to homepage instead of download file’ is closed to new replies.