How to only allow authenticated users to see organic groups

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
davidpugh's picture

Organic Groups: 7.x-2.6

I have a project that requires that only people who have logged in and are authenticated be allowed to view organic groups.
I've been searching around the net like crazy for an answer, and can't find one anywhere.
A lot of people have been wanting this feature for many years (since drupal 6).

Is there a workaround for this?
For Drupal 6 there is a workaround, as I found in this tutorial: http://www.sthlmconnection.se/en/blog/organic-groups-your-definition-public
But this doesn't work for Drupal 7 organic groups.
Even if OG maintainer decided right now that this should be added to the next OG version, I can't wait that long.

I would appreciate some advice on solving this issue. The tutorial that worked for Drupal 6 used hooks, but I think og_access_grants_alter is not a hook that is still available.

Lots of people are looking for this solution. If you know anything that could even help a bit, please do.

PS: I can't install the module "Content Access" or any other access control module to fix my problem, as I am already using "Domain Access" and "Organic Groups" together.

Comments

I think that is standard operation of OG 7

trainingcity's picture

If you check the OG configuration I think you will find that this type of behavior is standard in OG 7x.

admin/config/group/permissions

Allows you to set permissions for every content type and view permissions for EVERY individual field on each content type that is designated as of type "group". You should have permissions options for non-member, member (or whatever you call the OG members) and the Group Admin.

It is a bit of a pain to go through all these permission options for every single field, but that's life. The advantage is that you have very granular content access control based on OG membership.

permissions for member vs non member not enough

davidpugh's picture

Thank you for posting TrainingCity, but I need even more granular content access control.
I need:
1)Anonymous users should never be able to see a group, but the configuration on admin/config/group/permissions only lets you assign permissions via "member" "non member" or "admin member".
An anonymous person should never ever see a group, so the only option for your groups then would be "member", but then authenticated individuals would not be able to see any groups unless they were members of them.
I want authenticated users to be able to see groups they are not a part of. (while still not allowing anonynmous users to see groups)
The module "Content Access" gives this group content access control via "Authenticated" or "Anonymous", but I can't use Content Access with Domain Access and OG together.

From the solution people were coming up with in Drupal 6, it looks like this is only solvable with hooks.
Drupal 6 solution hooks (from tutorial link above):
node_access_explain($row)
node_access_records($node)
node_grants($account, $op)
og_access_grants_alter(&$grants, $node)

I was hoping that the same tutorial for Drupal 6 OG would work for Drupal 7 OG, but doesn't seem to.

If I am wrong about this not being a feature in OG 2.6 then please do elaborate.

Can't help with that

trainingcity's picture

I am not familiar with the Domain Access module, I prefer running multi-sites with separate dbs.

Content access is obviously the perfect solution for what you describe. Apart from a custom module, you might be able to use Rules, but I don't think so?

I suppose you could use the D7 node access module and setup for each OG content type node one by one:

https://drupal.org/project/nodeaccess

Here is an old summary of access modules:
https://drupal.org/node/270000

davidpugh's picture

It is not recommended using more than 1 access control module with Drupal.
I'm already using Organic Groups and Domain Access.
I will try Node Access (with my other access control modules), but since multiple access control modules can give you some very unexpected results, I am looking for a solution that does not include another access control module.
Custom solutions involving hooks are very welcome.
I would even appreciate it if you even have some idea why that
tutorial for the custom module to solve this for Drupal 6 (see link in original posting) does not work for Drupal 7.
I do appreciate your going out on a limb to help me out though, TrainingCity.

davidpugh's picture

Hello, I have found a solution that allows you to only allow authenticated individuals to see the group content, but it will only work if you are using Domain Access.
Domain access has a sub module called "Domain Strict", which allows you to set which users can access which domains, and which domains they can't access.
So for your domain that has your organic groups just set that domain to
not allow "Anonymous Users" to access that domain. For any of your other domains that require non authenticated access just set those domains to allow "Anonymous Users" to access those domains.
Drawbacks:
1)Domain Access specific solution
2)You can't have public content on the domain where your Organic Groups are located, as anonymous users would not be able to access it.

I am still interested in a NON Domain Access solution, so if you have one please post here for the people who need to solve this problem without Domain Access. (If it is a good solution I will probably use that over "domain strict")

Just create a role named

joshuautley's picture

Just create a role named "member" assign the role automatically when they register and deny access to that content for those without that role.

Organic groups

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week