5

I'm on Drupal 7 with Organic Groups installed. I've created a Private Group for my IT Team, meaning that only members of that group can see the group content.

The problem I'm seeing is that when I publish group content, Non-Members can still see the node link from the homepage, and click on it, even though the content is not displayed.

How can I make group content only visible to group members? (Meaning, the node itself is not visible to non-members.).

1
  • Any chance you could add some screenshots showing settings? Which version of OG are you using? Are you running straight 7 or a distro like Commons?
    – Rick
    Commented Sep 10, 2013 at 20:25

4 Answers 4

5

Please allow me to offer helpful insights even 6 months after your posted question. Hopefully, this will help others who are struggling with the Drupal module OG as well.

Note that in your content type, you should already have bundled Group content visibility as another field. Go to /admin/config/group/fields to accomplish this:

OG Field Settings

In this picture as my live example, note that my Content Group is the Group content type and that the Content Group Submission is the content type FOR hosting articles that should only be visible to any particular group. What you need to do is bundle Group content visibility as a new field for this content type as shown below.

Group content visibility field

This means that you will have Group content visibility field as an additional field to your own content type.

The Groups audience field is meant to make content authors specify the intended audience of the content they are authoring. The Group content visibility field is meant to make content authors specify the exposition criteria of that particular content. This is best shown in the following two pictures. Let us now look at the field set of my content type Content Group Submission. In my example, I went to /admin/structure/types/manage/content_group_submission/fields.

Manage the fields for the group's articles

If you edit this field, you will see its values to be constrained to the following options by default:

- None -, 
Use group defaults, 
Public, 
accessible to all site users

and Private - accessible only to group members.

The last one appears to be what you are interested in. You should make that as your default value for this field.

Editing the "Group content visibility" field

Save all of that. And your content authors will be offered with these options. In my case, go to /node/add/content-group-submission.

Adding an article for my group

And this is how your content authors would be able to constrain your article's exposition to only his/her intended groups. By this method, non-group members would not be able to see nor access the nodes (even titles only) that are intended for private groups where they do not belong.

3

If your content links are being displayed in a View, you need to configure the View with a Relationship to the OG user membership. Then, you will be able to set a filter to only display nodes of which a user is a current member.

1
  • Hi! Do you have more information with regards to this feature? I can't seem to find anything after adding the "OG memberships of field xx" relation. Commented Dec 12, 2014 at 15:30
1

another option is to make group content visible only to group member by default is to implement hook_node_access in a custom module like this:

/**
 * Implements hook_node_access()
 */
function mymodule_node_access($node, $op, $account){
    if($op=='view' && isset($node->og_group_ref[LANGUAGE_NONE])){
        $user=user_load($account->uid);
        $node_og_group_nid=$node->og_group_ref[LANGUAGE_NONE][0]['target_id'];
        $user_og_group_nid=$user->og_user_node[LANGUAGE_NONE][0]['target_id']; 
        if($node_og_group_nid!=$user_og_group_nid) return NODE_ACCESS_DENY;
    }
}
0

If you use the 'group content visibility' option, you will only hide the content, and you would still see the link as a non-member.

If you don't want the link to show up at all, you have to add the field "Group Visibility". To add the field go to /admin/config/group/fields.

This will hide the group link as well as all of the content inside.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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