diff --git a/chatroom.module b/chatroom.module
index 65ae32b..1c1271e 100644
--- a/chatroom.module
+++ b/chatroom.module
@@ -190,7 +190,21 @@ function chatroom_field_insert($entity_type, $entity, $field, $instance, $langco
     $chatroom->set('title', $item['chatroom']['chatroom_title']);
     $chatroom->set('public', $item['chatroom']['chatroom_public']);
     $chatroom->set('uid', $user->uid);
-    $chatroom->set('allowedRids', array($item['chatroom']['chatroom_roles']));
+    $allowed_rids = array();
+    foreach ($item['chatroom']['chatroom_read_only_roles'] as $rid) {
+      $allowed_rids[$rid] = (object) array(
+        'rid' => $rid,
+        'read_only' => 1,
+      );
+    }
+    // Just overwrite any read-only values for the same role.
+    foreach ($item['chatroom']['chatroom_write_roles'] as $rid) {
+      $allowed_rids[$rid] = (object) array(
+        'rid' => $rid,
+        'read_only' => 0,
+      );
+    }
+    $chatroom->set('allowedRids', $allowed_rids);
     if (isset($item['chatroom']['chatroom_format'])) {
       $chatroom->set('format', $item['chatroom']['chatroom_format']);
     }
@@ -227,7 +241,6 @@ function chatroom_field_update($entity_type, $entity, $field, $instance, $langco
         'read_only' => 0,
       );
     }
-    AD::ffs($allowed_rids);
     $chatroom->set('allowedRids', $allowed_rids);
     if (isset($item['chatroom']['chatroom_format'])) {
       $chatroom->set('format', $item['chatroom']['chatroom_format']);
