I'm new to Drupal and I absolutely love it! But I have a question I haven't been able to figure out.

I want to have 95% of my site accessible to anyone, and 5% accessible to people who create accounts and have to log-in to view it. I've looked but it seems you can either have the entire site restricted, or the entire site accessible. Is there any possible way to have a block or pages accessible to only people who log-in with made accounts, while the rest anyone can view? Thanks!

Comments

timatlee’s picture

You could use Taxonomy Access Control, or one of the other access control modules, and limit viewing for certain taxonomy terms to the authenticated user role. That would depend on the "public" content having one term, and the "private" content having another term.

I do this with my son's blog. Photos and blog entries can be marked private or public; private is available only to users who have logged in. I've then made users require my authorization before they can log in. Public photos and stories are, as the name suggests, public to anyone who views the site.

nancydru’s picture

For those of us who want to do this and are still new enough to be "taxonomy-challenged," could you provide more details on how to do this?

And, perhaps to take thie one step further, upon entry to the restricted section can I display different pages based on whether the user is authenticaed or not, for example, to the non-authenticated the page would say "You must be a member..." but the the authenticated we might say "Welcome, here you can do..."?

Thanks,
Nancy

timatlee’s picture

I can sure try...

This is all in 4.7, but I think it's the same in 5.0.

I'm just going to apply this to a story type; it can apply to any node type though.

Assuming TAC is installed and activated (see Admin -> Settings -> Taxonomy Access, make sure its set to Active)

I have 3 roles in total; Anonymous, Authenticated and a "Friends and Family" role that I created

Create your story category. For me, it was "news" with the vocabulary terms of "public" and "private".

Go to Admin -> Access Control, click on Category Permissions

You should see a list of roles here

Click on Anonymous User, then click the drop-down for "news".

Set the permissions as you see fit for Private and Public terms for the Anonymous user. For Private, I set everything as disable, and for public, I set View as Allow, everything else as disable.

Click Save Category Permissions, and repeat for Authenticated user. Since I wanted to allow anyone to sign up (helps with the whole login process) and I would add users I wanted to my own role, the Authenticated User permissions looks the same as my Anonymous user.

For my Family and Friends role, I set the Private term's View permissions to Allow. I also have List checked; can't remember now why I did that, but it seems to me I needed it. Experiment with it. :P

Good luck ...

The help file that comes with TAC is pretty good.. just take the time to read and experiment with it. If you have TAC installed, you can see the help file at help/taxonomy_access .

nancydru’s picture

I went with TAC_Lite and it seems to be doing almost everything I need. (I am on my way to post a feature request though.)

jptavan’s picture

Several contributed module provide public/private access :
http://drupal.org/project/Modules/category/74

"Taxonomy Access Control Lite" is one of them :
http://drupal.org/project/tac_lite

mr john’s picture

I'd like to allow people to specify if their node can be viewed by friends, family, everyone or no one (besides them and the admin). Is there a way to do this using some access control module?

nancydru’s picture

That's what this thread is about. Based on previous answers, I installed Tac_Lite. It is doing just what you want. My roles are different, but the result is the same.

Reading the documentation it can look a bit overwhelming, but it isn't as bad as you might think. In the documentation, there is a link to a flash "movie" that shows you some of what you can do - watch it a couple of times. Then read the install.txt file that comes with the module. Then watch the movie again.

One word of warning, though, Tac_Lite needs (wants?) the Devel and Views modules. I think the Views module is okay. But the Devel module causes me some Admin heartburn. It shows me a bunch of stuff I don't really want to see, and when I create new content, I don't get redirected to it - I just see a message saying I'll be redirected, but it never goes. And if I click on the redirect link, I get logged out. Get friendly with your Back button.

mr john’s picture

I watch the movie and it definitely helped. As far as I can tell, I would need to create a:
friends
family
category for each user. E.g.,

john's friends
john's family
nancy's friends
nancy's family
etc.

Is that correct? In order for john to give make nancy a friend, someone would need to modify nancy's profile to include them in the friends category for john.

A public category would also need to be created where all users are included?

Is this correct? Is there an easier or better way?