Get group id i have a topic id

hi, I want to get group id in the bases of topic id in discourse so if anyone does this type of job please help me.

1 Like

What are you trying to do? Do you want to change permissions for many categories to allow/deny access by certain groups?

4 Likes

i have a topic id and i want to get group id for this topic

1 Like

Group access to topics is controlled by the topic’s category. This is stored in the category_groups table. As an example, if you have assigned the topic to the variable t, you can find its category_groups with:

category_groups = CategoryGroup.where(category_id: t.category_id)

That will return an array of CategoryGroup records. The records will be similar to this:

id: 66,
category_id: 23,
group_id: 49,
created_at: Thu, 02 Jan 2020 18:17:55 UTC +00:00,
updated_at: Thu, 02 Jan 2020 18:17:55 UTC +00:00,
permission_type: 1
5 Likes