• I’m looking for suggestions how to approach this:

    I have a free website but want to restrict some of the content download to registered users. It is a bit complicated scenario but what I need is basically that a folder is protected via .htaccess and this .htaccess folder can be accessed by users with their wp user login details.

    My idea is currently to do the following (probably not very elegant way of doing this…):

    1. Find the hooks / actions that register / update user details.
    2. Write a script that whenever a new user registers or updates his details the whole member details are read out and a new .htaccess file is written in the folder that I want to protect.

    I would appreciate suggestions for a better way to do this and I don’t really know where to start right now and what hooks / actions I should look at.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jayschmidt

    (@jayschmidt)

    I got it working with mysql_mod_auth.

    Although you’ve solved it with an external mod, I would like to suggest it would probably be easier in the long run to do this simply by using a custom field in the user profile to determine who can/cannot access the files.

    Then use a WordPress page to do the checking and sending of the files. This gives you more flexibility in the long run and easier to maintain.

    If you want to use WordPress user data, creating a Page is a better way because you have access to the is_user_logged_in function. This page can be a custom page template where you simply list all of the files from that directory.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Use the wp user data to protect a folder with .htaccess’ is closed to new replies.