Categories
Code WordPress

How I fixed WP-DownloadManager 404 errors

Lester Chan's header
I use LesterChan‘s Download Manager plugin, and it’s great. Good interface, simple purpose. 

I recently found out that after upgrading a client’s site to WP 2.5, WP-DownloadManager was no longer working.  I followed the documentation on the plugin website, including resetting the permalink structure, but nothing worked.

For some reason the re-write wasn’t working properly: all the downloads were giving 404 errors.  I couldn’t figure it out, so I dove into the code.  I found the part of the plugin that rewrites the download links, and found the problem.

Here’s the fix I found hack:

The plugin uses a function on line 271 of downloadmanager.php that may not be working because of WP 2.5: download_file_url.

Here’s the original code:

### Function: Download URL
function download_file_url($file_id) {
$file_id = intval($file_id);
if(get_option('permalink_structure')) {
$download_file_url = get_option('siteurl').'/download/'.$file_id.'/';
} else {
$download_file_url = get_option('siteurl').'?dl_id='.$file_id;
}
return $download_file_url;
}

I highlighted the part of the code that was causing me issues, and removed that if/else.

Updated code:

function download_file_url($file_id) {
$file_id = intval($file_id);
/* if(get_option('permalink_structure')) {
$download_file_url = get_option('siteurl').'/download/'.$file_id.'/';
} else {
$download_file_url = get_option('siteurl').'?dl_id='.$file_id;
} */

$download_file_url = get_option('siteurl').'?dl_id='.$file_id;
return $download_file_url;
}

In summary

This may or may not have been a WordPress upgrade issue, but it did solve my problem, and I didn’t need to delve any further into the root cause.

Please post any comments or corrections below.

By Zack Katz

Zack Katz is the founder of GravityKit and TrustedLogin. He lives in Leverett, Massachusetts with his wife Juniper.

5 replies on “How I fixed WP-DownloadManager 404 errors”

Thanks for the post. Can I know what is your permalink structure? I can’t seem to reproduce this problem. I upgraded my live and localhost to WP2.5 from Wp2.3.3 and the download seems to works fine.

@ GaMerZ – The permalink structure for the site is:
/%year%/%monthnum%/%day%/%postname%/
The download page on the website is Relationship Rules speaker’s kit.

It may or may not be a WP 2.5 issue, but updating the site to 2.51 is when I noticed the plugin no longer worked.

I also using the same permalink. In 1.30 Beta 4, I have added an option for you to whether to use nice permalink for downloadmanager. If you choose no, it will use the dl_id.

Thanks for the feedback =D

Comments are closed.