Rooms
Rooms are the top-level organization of the forum. Each room is an of_room CPT post with settings stored in post_meta.
Room properties:
| Property | Meta Key | Description |
|---|---|---|
| Name | post_title | Display name |
| Slug | post_name | URL slug |
| Description | post_content | Room description |
| Icon | of_room_icon | Emoji or text icon |
| Color | of_room_color | Hex color for accent |
| Visibility | of_room_visibility | public, members, or role |
| Required Role | of_room_required_role | WP role slug (for role-gated rooms) |
| Sub-room of | post_parent | Parent room ID (0 = top-level) |
| Menu Order | menu_order | Display sort order |
Creating a room (PHP):
php$room_id = OF_Rooms::create([
'name' => 'General Discussion',
'icon' => '💬',
'color' => '#38BDF8',
'visibility' => 'public',
]);
Getting rooms:
php$rooms = OF_Rooms::get_all(); // All rooms (flat array)
$rooms = OF_Rooms::get_all(false); // Top-level rooms only
$room = OF_Rooms::get($room_id); // Single room by ID
$room = OF_Rooms::get_by_slug('general-discussion');
Visibility check:
php$can_view = OF_Rooms::user_can_view($room_id, $user_id);
Sub-rooms
Set sub_room_of to a parent room ID when creating a room. Sub-rooms appear indented on the forum index under their parent room. Sub-rooms support one level of nesting.
