Hello :o)

I'm in the midst of trying to create a highly democratised environment, where users joining organic groups effectively create a 'poll', with which the existing members of the group vote on whether the prospective member can join or not. Once a percentage of the current members have voted favourably, the prospective member is admitted to the group - thus reducing the absolute power a group admin holds over the membership.

Has anyone out there achieved this, or anything even close to it?

-- J.

Comments

therealwebguy’s picture

Sounds like you are going to be faced with some customized code for this to work.

I would start by creating your own custom module and call it something like "og_groups_helper.module". This module will control any custom functionality outside of the og.module currently.

You could start by doing a form_alter on the poll's form id in your new og_groups_helper.module and then add in an addition custom submit hook, which allows you to do additional handling when a poll vote is submited. You could start by checking the total votes for the current user and if it is great enough to apply the user to the group, directly call og_save_subscription and pass it the group id of the group the user should be saved to, the user id of this user, and any additional args if there are any for the function.

Here is an example of what I am suggesting.

og_groups_helper.module

function og_groups_helper_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'poll-view-voting':
      $form['submit'] = array('og_helper_module_poll_submit') + $form['submit'];
      break;
  }
}

function og_groups_helper_poll_submit($form_id, $form_values) {
  // A few things need to take place in this function.
  // 1. You need to now query for the results of the poll, to find the vote status for the desired user.
  // 2. If the vote status is enough, you need to get the user id of that user and the group id of the group you want to store them too.
  // 3. Call og_save_subscription($gid, $uid, $attributes = array()) to save the user to the group.
}

I hope this gets you on the right path to being able to do this. Using two contrib modules with each other is not an easy task and requires some custom code and usually a middle man module. If you have more questions or any specific questions to this reply, please post. I will continue to follow this post as I am interested in making this work for you.