diff --git a/og_user_roles.module b/og_user_roles.module
index 134552e..181e926 100644
--- a/og_user_roles.module
+++ b/og_user_roles.module
@@ -162,10 +162,18 @@ function og_user_roles_determine_context() {
     $node = $object;
   }
   // Check if we are in the node add page.
-  elseif (strpos($path, 'node/add') === 0 && !empty($_REQUEST['gids'])) {
+  elseif (preg_match('@^node/add/([^/\?]*)', $path, $matches) > 0) {
     // URL pattern: node/add/story?gids[]=1
-    $gid = intval(current($_REQUEST['gids']));
-    $node = node_load($gid);
+    $content_type = $matches[1];
+    if (module_exists('og_subgroups') && og_is_group_type($content_type) && (!empty($_REQUEST['og_parent']))) {
+      $gid = intval(current($_REQUEST['og_parent']));
+    }
+    elseif ((og_is_group_post_type($content_type)) && (!empty($_REQUEST['gids']))) {
+      $gid = intval(current($_REQUEST['gids']));
+    }
+    if (isset($gid)) {
+      $node = node_load($gid);
+    }
   }
   elseif ((!empty($item['map'][0]) && $item['map'][0] == 'og' && !empty($item['map'][2])) || $path == 'comment/reply/%') {
     if (is_numeric($item['map'][2])) {
