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:
- Create a custom post type for the private content
- Create a custom taxonomy for Clients
- Hook
user_register
and add a Client (taxonomy) every time a new user is created - 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?