We’re rewarding the question askers & reputations are being recalculated! Read more.
17

Here's how you can do it with views in Drupal 7. Create a new view of nodes as you normally would, but make sure you set up the appropriate relationship for it that will allow you to filter your nodes based on their group membership: Add a relationship (under the 'Advanced' section of the view) Select the 'OG membership: OG membership from Node' field, ...


16

I finally figured it out: (enlarge image) The steps are: create a view for "content" type "group". Use "fields" and show "content:title", that's the name of your group add relationship "Group: Node group" (required), then "(group) Organic groups group: OG membership" (required). add filter "(OG membership) OG membership: Entity_type " and set to "is ...


15

You need to enable og access control module. see below: Then navigate to admin/config/group/fields, add an visibility field to your og bundle Then edit the og bundle content type, there is a new field added to it, make your change for public or private


14

Using directly the Organic Groups API: og_get_group_members_properties($yourGroupNode, array(), 'members', 'node'); gives you an array of user ids. To obtain only active, pending or blocked users, you can put 'members__1', 'members__2' or 'members__3' in place of 'members', like in this example: og_get_group_members_properties($yourGroupNode, array(), '...


13

I figured it out. It ended up not working because the group ID is NOT the same as the node ID for that organic group. Here is the working version: function MYMODULE_page_form_submit($form_id, $form_values) { global $user; $node = new stdClass(); $node->type = "group"; $node->uid = $user->uid; $node->title = ...


13

Since OG7-2.x the node ID == group ID, there is no need to use og_get_group(). And in og_group() and og_role_grant() your group type is the first argument. So here is the same code for OG 7.x-2.x function MYMODULE_page_form_submit($form_id, $form_values) { global $user; $node = new stdClass(); $node->type = "group"; $node->uid = $user->...


11

Or via DBTNG: $query = db_select("og_membership", "ogm"); $query->condition("ogm.gid", $yourGroupID, "="); $query->condition("ogm.group_type", "node", "="); $query->fields("ogm", array("entity_type", "etid")); $result = $query->execute(); print_r($result->fetchAll()); ...which allows you to join other tables, rather than having to filter the ...


11

The relationship between group content and a group is via a membership relation. Since it is possible for group content to be a member of multiple groups then the following code will retrieve the list of groups: $groups = og_get_entity_groups('node', $node); This is a multidimensional array with the group entity_types as the key and memberships as the ...


11

This is how to get the OG membership ID:s to start with. Add new view. Show -> OG membership (important!) Then in some display add a contextual filter -> OG membership: Entity id. Provide default value -> Type -> User ID from logged in user. Override title: %1's groups. Specify validation criteria -> User. Now you have the list of ID:s. Next to get the ...


10

1. Users can create groups: To create groups you just create a new content type "groups" and with permissions for users to create new content. I also added an image field to allow uploading a group logo. 2. Users can join groups (and leave them) without approvals or permissions The Flag module turned out to be an excellent way to allow users to join (and ...


8

$query = new EntityFieldQuery(); $query ->entityCondition("entity_type", "og_membership", "=") ->propertyCondition("gid", $yourGroupID, "="); $result = $query->execute(); print_r($result["og_membership"]); (Based on http://api.drupal.org/api/drupal/includes--common.inc/function/entity_load/7#comment-14544)


8

Assuming you are using Drupal 7 and latest OG you can use og_get_groups_by_user(). Get the group IDs of all the groups a user is an approved member of.


8

If you temporarily disable og_workbench and it's still happening, you have a bigger problem. Was OG upgraded from 1.x -> 2.x? I've found myself in this situation a few times during og upgrades. First, check to make sure all the OG Migrations have been run at admin/content/migrate. There is a migration named OgMigrateRoles that is often 0 of 0. Even ...


8

I managed to get this working. These very short instructions are indeed correct. But the first few times I tried to follow them I did not have any success. Therefore I thought it would be useful to explain the steps and potential pitfall in more detail. I have broken this answer up into two parts. You may have already done the work in Part A of these ...


8

About The Group module allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections. It is available as of D7, and has a D8 version also. It is designed to be an alternative to Organic Groups. Organic Groups allows content itself to be groups, which isn't always what people want....


7

I don't think that there is a page you can view the membership. I've just skimmed the code of OG module and didn't found any relating part which displays a membership in a separate page. However, since memberships are entities, it should be possible that you can setup a view which takes a membership id as contextual filter and display it in a selected view ...


6

Okay so I'm assuming that you haven't used Migrate before. If you'd like some background reading take a look at the slides for the presentation I'll be giving at DrupalCon in Denver: http://denver2012.drupal.org/sites/default/files/slides/Migrate_0.pdf It should help you understand some of the concepts. One thing that's important to point out is that you'll ...


6

For the 7.x-2.x branch of Organic Groups you need to use the following code. og_is_member('node', $gid, 'user', $user) 'node' is the entity type. The function og_is_member requires 4 parameters to return the correct value.


6

Under Relationships, I choose "OG membership: OG membership from Node". Then under Contextual Filters, I choose "OG membership: Group ID". The last step is to select the Provide default value and choose "Type: Current OG group from context" under the WHEN THE FILTER VALUE IS NOT IN THE URL heading. Attached is a picture of what I mean. Contextual Filter ...


5

First in your .install when creating your content type, add: og_create_field(OG_AUDIENCE_FIELD, 'node', 'bundle_name_of_your_content_type'); Then when you need to assign a fresh new content of your content type to an existing group, you can do it in two ways: 1) Found it http://drupal.org/node/1249396#comment-4885442 and thanks to tenken $node = ...


5

You can also just add the 'element-hidden' CSS class to the form element $form['user_edit_about']['group_audience']['#attributes']['class'][] = 'element-hidden'; As iStryker mentioned previously, it would still be possible to change the value through DOM manipulation. However, this is a nice, easy way to hide a form field (or any other render element). The ...


5

In Drupal 7 for the For the 7.x-1.x branch of Organic Groups, you can use og_is_member(). $gid = 12; if (og_is_member($gid)) { drupal_set_message('Current logged in user is member'); } $gid = 12; $account = user_load(3); if (og_is_member($gid, 'user', $account)) { drupal_set_message('User id 3 is member of group 12'); }


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: In this picture as my ...


5

OG provides no access control on attached files. I ran into the same situation and came up with two options. The file depot module integrates nicely with OG and does prevent users who are not members of a group from accessing files that are attached to a group. The filedepot module is full featured Document Management module that has a google docs like ...


5

@potney i have updated your code.Please check drupal_add_http_header('Content-Type', 'text/csv; utf-8'); drupal_add_http_header('Content-Disposition', 'attachment;filename=csvfiles.csv'); $output = ''; $keys = array(t('User id'), t('Username'), t('Email')); if ($keys) { $output .= implode("\t", $keys) . "\n"; } $members = _get_users_in_group($gid); ...


4

For OG 7.x-1.x, I discovered that simply by enabling the Rules module, email notification Rules from OG are made active. That did the trick for me. (Not sure about OG 7.x-2.x, which makes mention of the Message_Notify module on the OG project page...)


4

Here's a simple solution: Create a content type, say 'proposal', that any user can add for the petition group (with title as group name and body for reason). Users can comment on nodes of that type so they can discuss the proposal. Create a view to show nodes of type 'propsal' and enable filtering, sorting etc. Use the Votingapi module and one of the ...


4

You should write a custom module that implements hook_form_alter(). Get the $form_id of the 'create new user' form that you want to alter. ( drupal_set_message($form_id); is an easy way to do this. ) Add a custom submit handler to the 'create user' form that uses the respective details and the og_group() function to add the new user to the group. ...


Only top voted, non community-wiki answers of a minimum length are eligible