diff --git a/og_user_roles.module b/og_user_roles.module
index 134552e..dbb110c 100644
--- a/og_user_roles.module
+++ b/og_user_roles.module
@@ -355,7 +355,7 @@ function og_user_roles_grant_roles(&$account, $group_node = NULL) {
     $placeholders = db_placeholders($args);
     array_unshift($args, $account->uid);
     // INNER JOIN as extra sanity check (not only for role name).
-    $result = db_query("SELECT ogur.rid, r.name FROM {og_users_roles} ogur INNER JOIN {role} r ON r.rid = ogur.rid WHERE ogur.uid = %d AND ogur.gid IN ($placeholders)", $args);
+    $result = db_query("SELECT ogur.rid, r.name FROM {og_users_roles} ogur INNER JOIN {og_uid} oguid ON oguid.nid = ogur.nid AND oguid.uid = ogur.uid AND is_active = 1 INNER JOIN {role} r ON r.rid = ogur.rid WHERE ogur.uid = %d AND ogur.gid IN ($placeholders)", $args);
     while ($role = db_fetch_object($result)) {
       // Add roles to account first, so we can statically cache all roles
       // afterwards.
