Hi,

I was thinking about using Membership types in what I thought being a standard usecase, but either it's not that standard, or OG does not allow that.

My usecase:

  • I have a simple OG structure: Group CT for groups, Group page CT for group contents
  • Only admins can create groups, and group contents
  • Anon and auth users can ask to subscribe a group (become a member, I don't have the right wording here), it's moderated so admin must validate (or not)
  • Even if users are logged-in to subscribe, we would like to ask them more information about them before validating their subscription. These information depends on groups, or at least on different sets of groups
    • Basically each group has a type (Communication, Marketing, HR, ...) which is at the moment simply implementing as a new field in the Group CT
    • We would like to have a specific membership type (so membership form) depending on this type.

If it was possible to put this Membership Type as a field into the Group CT directly, it could be itself the Group type. Therefore an admin create a group, select which type it is (or which Membership Type it has, nevermind), and that's it. Then each user that want to subscribe on this group needs to fill this form.

I read few things around this topic, mainly https://www.drupal.org/node/1871220 and https://www.drupal.org/node/1168428 but I was not able to configure this usecase. As far as I understood, a membership type does not apply on the group itself, but on the group audience field, which does not really make sense for me because:

  • Group Page CT has only one Audience field, so I can define only one Membership type
  • Even if I can add multiple here, why should I have multiple Audience for a single CT?
  • The group audience is usually defined on the Group Content CTs, not on Group CTs, so it means the membership type is defined in the Group Content, no in the Group
  • Why adding a membership type into the User entity? Especially because I don't want to let them choose which membership type they want, it must be defined by the group admin only

I hope you could have understand my usecase and tell me either if it's doable or if I miss the way it works.

Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Antoine Vigneau created an issue. See original summary.

Antoine Vigneau’s picture

I tried a naïve solution, that basically hacks og.module. I'm not that keen on that of course, but just want to share it to know if it's relevant. The patch is awful, not generic, I know it's bad, just a starting investigation...

--- og.module	(revision 4134)
+++ og.module	(working copy)
@@ -1273,8 +1273,10 @@
   }
 
   // Get the type from the field.
-  $field = field_info_field($field_name);
-  $values['type'] = $field['settings']['handler_settings']['membership_type'];
+  $group_node = node_load($gid);
+  $membership_type_entities = entity_load('og_membership_type', array($group_node->field_memberhsip_type[LANGUAGE_NONE][0]['target_id']));
+  $membership_type_entity = array_pop($membership_type_entities);
+  $values['type'] = $membership_type_entity->name;
 
   $wrapper = entity_property_values_create_entity('og_membership', $values);
   return $wrapper->value();

I created a field_memberhsip_type in my Group CT (entity ref on og_membership_type), so from my Group edit form, I can choose my Membership type. Then in og_membership_create() instead of using the 'membership_type' setting defined in the $field_name (group audience), I use my own value. So far it works, and the usecase sounds more interesting to me, is it only me?

amd.miri’s picture

Hello,
Based on previous comment by Antoine , I created a patch that adds a group admin page where you can select between the existing membership types. in this way, it's not necessary to create a field and hard-code the machine name of the field inside the code.
Regards

amd.miri’s picture

Hi, I'm sending a better patch as there were some small issues with the previous one.
Cheers