--- og_user_roles.module.orig	2008-12-16 21:41:21.306774800 +0100
+++ og_user_roles.module	2008-12-16 21:11:01.834163200 +0100
@@ -2504,16 +2504,25 @@ function og_user_roles_getgid($nid, $uid
     }
   }
 
-  // If $gid still equals 0 then try searching node_access table
-  /* Sample:
-   * SELECT node_access.gid from node_access INNER JOIN og_uid ON node_access.gid = og_uid.nid WHERE node_access.realm = 'og_subscriber' AND og_uid.uid = 2 AND (node_access.nid = 194 OR node_access.gid = 194)
-   */
+  // If $gid still equals 0 then try searching node_access table,
+  // checking both the node and group ID. These queries can't be
+  // combined without degrading performance.
+  //
+  /* Sample:
+   * SELECT node_access.gid from node_access INNER JOIN og_uid ON node_access.gid = og_uid.nid WHERE node_access.realm = 'og_subscriber' AND og_uid.uid = 2 AND (node_access.nid = 194 OR node_access.gid = 194)
+   */
   if ($gid == 0) {
-    $result = db_query("SELECT na.gid from {node_access} na INNER JOIN {og_uid} ogu ON na.gid = ogu.nid WHERE na.realm = 'og_subscriber' AND ogu.uid = %d AND (na.nid = %d OR na.gid = %d)", $uid, $nid, $nid); // modified to check for either the node or group ID in node_access
+    $result = db_query("SELECT na.gid from {node_access} na INNER JOIN {og_uid} ogu ON na.gid = ogu.nid WHERE na.realm = 'og_subscriber' AND na.nid = %d AND ogu.uid = %d", $nid, $uid);
     while ($t = db_fetch_object($result)) {
       $gid = $t->gid;
     }
-  }  
+  }
+  if ($gid == 0) {
+    $result = db_query("SELECT na.gid from {node_access} na INNER JOIN {og_uid} ogu ON na.gid = ogu.nid WHERE na.realm = 'og_subscriber' AND na.gid = %d AND ogu.uid = %d", $nid, $uid);
+    while ($t = db_fetch_object($result)) {
+      $gid = $t->gid;
+    }
+  }
 
   // If $gid still equals 0 then try searching og_term table (if it exists)
   // og forums will typically be listed here
