Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

A common requirement for business sites is to have a client login which allow visitors to access private content for them (ie: downloads, screenshots, documents).

I did it in the past and although it worked, I think is a bit messy.

Now I need the same functionality in a new site, and want to know if anyone did it and want to share a nice way to achieve this.

My method was something like:

  1. Create a custom post type for the private content
  2. Create a custom taxonomy for Clients
  3. Hook user_register and add a Client (taxonomy) every time a new user is created
  4. Hook template_redirect and check if it's a single of my custom post type. If it is, check if the logged_in user is in the custom taxonomy for that post. If it is, cool. If not, header('HTTP/1.1 401 Unauthorized');exit;

Any comments?

share|improve this question
add comment

1 Answer

Sound like a nice idea, but when i need a per user customized private section i usually code it based on page template files and create a few pages with these template files fo example, say i have a download page which will show each user the files he can download so my page template would

first check if the user is logged in (if not Unauthorized redirect) then just pull all of the file that user can download.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.