Forums

Using WordPress Authentication (6 posts)

  1. the_dead_one
    Member
    Posted 7 years ago #

    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?

  2. Kafkaesqui
    Moderator
    Posted 7 years ago #

    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.

  3. the_dead_one
    Member
    Posted 7 years ago #

    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. :)

  4. Kafkaesqui
    Moderator
    Posted 7 years ago #

  5. Matt Mullenweg
    Troublemaker
    Posted 7 years ago #

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

  6. chrisdawson
    Member
    Posted 5 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.