diff --git a/og.module b/og.module index 34d8121..b4be82e 100644 --- a/og.module +++ b/og.module @@ -2188,13 +2188,17 @@ function og_user_access_entity($perm, $entity_type, $entity, $account = NULL) { if ($is_group_content && $groups = og_get_entity_groups($entity_type, $entity)) { foreach ($groups as $group_type => $gids) { - foreach ($gids as $gid) { - if (og_user_access($group_type, $gid, $perm, $account)) { - return TRUE; + // make sure og context exists + $entity_groups = entity_load($group_type, array_keys(array_flip($gids))); + if (!empty($entity_groups)) { + foreach (array_keys($entity_groups) as $gid) { + if (og_user_access($group_type, $gid, $perm, $account)) { + return TRUE; + } } + return FALSE; } } - return FALSE; } // Either the user didn't have permission, or the entity might be a