diff --git a/regcode_og/regcode_og.module b/regcode_og/regcode_og.module
index 19f90f6..55e111b 100644
--- a/regcode_og/regcode_og.module
+++ b/regcode_og/regcode_og.module
@@ -1,10 +1,15 @@
 <?php
 
 /**
- * TODO this function no longer exists in D7!
+ * Retrieves list of organic groups
  */
 function og_all_groups_options() {
-  return array();
+   $groups = array();
+   $gids = og_get_all_group();
+   foreach($gids as $gid) {
+      $groups[$gid] = og_label($gid); 
+   }
+   return $groups;
 }
 
 
@@ -162,7 +167,7 @@ function regcode_og_get_rules($tags = array(), $list_all = FALSE) {
     $res = db_query($query);
   }
   else {
-    $res = db_query($query . ' WHERE term_data.tid IN (%s)', $tid_string);
+    $res = db_query($query . ' WHERE term_data.tid IN (' . $tid_string . ')');
   }
 
   return $res->fetchAll(PDO::FETCH_ASSOC);
@@ -200,6 +205,6 @@ function regcode_og_regcode_used(&$edit, &$account, $regcode) {
 
   // Apply the rules
   foreach ($rules as $rule) {
-    og_save_subscription($rule['ogid'], $account->uid, array('is_active' => 1));
+    og_group($rule['ogid'], array('entity' => $account));
   }
 }
