--- og_user_roles.module.5.x-3.4.orig	2009-01-12 11:07:30.000000000 -0800
+++ og_user_roles.module	2009-01-12 11:18:35.000000000 -0800
@@ -1,5 +1,5 @@
 <?php
-// $Id: og_user_roles.module,v 1.1.2.17 2008/11/24 18:14:04 somebodysysop Exp $
+// $Id: og_user_roles.module,v 3.1.1.2 2008/05/17 19:50:44 somebodysysop Exp $
 
 /**
  * @file
@@ -2318,6 +2318,13 @@ function og_user_roles_all_roles($user) 
         // Set group context.
         $group_node = node_load($gid);
         og_set_group_context($group_node);
+	  } else {
+        if ($_SESSION['og_user_role']) {
+          $gid = $_SESSION['og_user_role'];
+          // Set group context.
+          $group_node = node_load($gid);
+          og_set_group_context($group_node);
+	    }
 	  }
 	}
 
@@ -2417,7 +2424,7 @@ function og_user_roles_all_roles($user) 
   if (empty($gid)) {
     $gid = 0; // This prevents us from getting error on non-group node/add
   }else{
-    $_SESSION['og_last']->nid = $gid;
+    if (is_object($_SESSION['og_last'])) $_SESSION['og_last']->nid = $gid;
     $_SESSION['og_user_role'] = $gid;
   }
 
@@ -2632,6 +2639,8 @@ function og_user_roles_ognodeadd() {
   $type = $_GET['type'];
 
   if ($type) {
+    // Convert the dashes in the URL back to underscores. http://drupal.org/node/349648
+    $type = str_replace('-', '_' , $type);
     // Got this from node.module (node_access)
     // No matter the type, this should return us the create permission.
     $module = node_get_types('module', $type);
