Hi dear drupalers,
I'm pulling my hairs to solve a need case, and i will apreciate any help in advance !
I need to present og in the registration form using selects rather than checkboxs like it's by default !
Any ideas ?

Comments

epruett’s picture

I found these two modules that may be solutions:
http://drupal.org/project/og_reg_codes
http://drupal.org/project/og_profiles

I'm sure there is more at Drupal.org

bnadem’s picture

Thanks you very much for replying ;)
I will follow your hints and come with feed back.

bnadem’s picture

Hi,
I achieved that by hacking the "og.module" file in the og module directory,
Look for this section:
-------------------------------------------------------------------------------------------------------

function og_user($op, $edit, &$account, $category = NULL) {
  global $user;

  switch ($op) {
    case 'register':
      $options = array();
      list($types, $in) = og_get_sql_args();

      // If groups are passed on querystring, just use them.
      if (isset($_REQUEST['gids']) && $gids = $_REQUEST['gids']) {
        $default_value = $gids;
        foreach ($gids as $gid) {
          $nids[] = (int)$gid;
        }
        $in_nids = db_placeholders($nids);
        $sql = "SELECT n.nid, n.title, o.* FROM {node} n INNER JOIN {og} o ON n.nid = o.nid WHERE n.type $in AND n.status = 1 AND n.nid IN ($in_nids) ORDER BY n.title";
        $result = db_query(db_rewrite_sql($sql), array_merge($types, $nids));
      }
      else {
        $default_value = array();
        // perhaps this should be a View
        $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, o.* FROM {node} n INNER JOIN {og} o ON n.nid = o.nid WHERE n.type $in AND n.status = 1 AND o.og_register = 1 ORDER BY n.title"), $types);
      }

      while ($group = db_fetch_object($result)) {
        $options[$group->nid] = '<span class="og-registration-'.$group->nid.'">'. t('Join %name.', array('%name' => $group->title)). "</span>\n";
        if ($group->selective) {
          $options[$group->nid] .= ' '. t('(approval needed)');
        }
      }

      if (count($options)) {
        $form['og_register'] = array('#type' => 'fieldset', '#title' => t('Groups'));
        $form['og_register']['og_register'] = array(
          '#type' => 'checkboxes',
          '#options' => $options,
          '#default_value' => $default_value,
        );
        return $form;
      }

-------------------------------------------------------------------------------------------------------
And replace it with this:

--------------------------------------------------------------------------------------------------------

function og_user($op, $edit, &$account, $category = NULL) {
  global $user;

  switch ($op) {
    case 'register':
      $options = array();
      list($types, $in) = og_get_sql_args();

      // If groups are passed on querystring, just use them.
      if (isset($_REQUEST['gids']) && $gids = $_REQUEST['gids']) {
        $default_value = $gids;
        foreach ($gids as $gid) {
          $nids[] = (int)$gid;
        }
        $in_nids = db_placeholders($nids);
        $sql = "SELECT n.nid, n.title, o.* FROM {node} n INNER JOIN {og} o ON n.nid = o.nid WHERE n.type $in AND n.status = 1 AND n.nid IN ($in_nids) ORDER BY n.title";
        $result = db_query(db_rewrite_sql($sql), array_merge($types, $nids));
      }
      else {
        $default_value = array();
        // perhaps this should be a View
        $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, o.* FROM {node} n INNER JOIN {og} o ON n.nid = o.nid WHERE n.type $in AND n.status = 1 AND o.og_register = 1 ORDER BY n.title"), $types);
      }

      while ($group = db_fetch_object($result)) {
        $options[$group->nid] = $group->title;//Modified
        if ($group->selective) {
          $options[$group->nid] .= ' '. t('(approval needed)');
        }
      }

      if (count($options)) {
        $form['og_register'] = array('#type' => 'fieldset', '#title' => t('Groups'));
        $form['og_register']['og_register'] = array(
          '#type' => 'select',//Modified
          '#options' => $options,
          '#default_value' => $default_value,
        );
        return $form;
      }

-------------------------------------------------------------------------------------------
I modified the field type used to present groups on registration form from "checkboxes" to "select"
Then, I prevented the printed variables from being themed.
This has the advantage of presenting groups on registration form in a compact way, and prevent user from subscribing to more than a group when it's needed.
Hope this helps someone.

izmeez’s picture

This looks useful although I haven't yet tested it. Got here from a link in http://drupal.org/node/990094

Since this is posted in the forums I wonder if you might post it as a patch in the other thread which is in the og issue queue where it can be reviewed and maybe committed.

truyenle’s picture

Yeah, patch only changes the UI on the registration form but user doesn't really add in as a member of the og.

pierredvumali’s picture

the patch has been a big help. thanks a lot!

pierredvumali’s picture

after I have tested it, it is not working. It only changed the UI in the registration page. do you have any new patch that I can test?