• Is it possible to use WordPress Authentication on file downloads?

    What I mean is that I’ve created a site with the View Level plugins so some of the posts are not avaliable unless your registered and have level 1.

    But I have some files that users may wish to download and I want to have the same restriction on downloading the files (i.e. only registered users with user level at least 1).

    Is there a way to do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Strangely enough, I’m wrangling with a plugin idea for downloads. Wouldn’t be difficult to slip user (and user level) checking into it as an option.

    The way it works is, you create a specific download directory for files and set a variable in the plugin to point to that directory. To download files, you’d use the ‘dl’ query with a filename as value:

    index.php?dl=thisismystuff.zip

    The plugin’s still a few days off from being release-worthy, but let me know if this fits your needs.

    Thread Starter the_dead_one

    (@the_dead_one)

    I had started to think about how you could do it as a plugin too. Sounds like you have it mostly figured out and it seems to be exactly what I ‘m looking for!

    Keep me informed! Thanks. ??

    You could just include wp-config.php and check for $current_user to see if they’re signed in.

    Thanks matt. Note that if the page you need to authenticate is somewhere on your site other than under the WordPress root directory, you need to change the COOKIEPATH definition in wp-settings.php so that the auth cookie applies there as well.

    I found that

    define('COOKIEPATH', '/');

    did the trick!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Using WordPress Authentication’ is closed to new replies.