# Kan een plugin automatisch een topic aanmaken na het aanmaken van een categorie?

**URL:** https://meta.discourse.org/t/can-a-plugin-auto-create-a-topic-after-create-of-a-category/177698
**Category:** Development
**Created:** [29 januari 2021 om 17:54 UTC](https://meta.discourse.org/t/can-a-plugin-auto-create-a-topic-after-create-of-a-category/177698 "2021-01-29T17:54:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![frank.manuel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frank.manuel/32/203348_2.png) [@frank.manuel](https://meta.discourse.org/u/frank.manuel)
#### Post date: [29 januari 2021 om 17:54 UTC](https://meta.discourse.org/t/can-a-plugin-auto-create-a-topic-after-create-of-a-category/177698/1 "2021-01-29T17:54:19Z")

</div>

I want every category to have an auto-generated topic, much like default “About the [catgegory name] category” at the top of every category. Is there a way I can hitch on the after\_create event of Category? I can’t find any plugin that does anything similar, or even how to insert a topic record.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [1 februari 2021 om 02:21 UTC](https://meta.discourse.org/t/can-a-plugin-auto-create-a-topic-after-create-of-a-category/177698/2 "2021-02-01T02:21:50Z")

</div>

I think you’d need to use the Discourse API to achieve this?

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [1 februari 2021 om 03:21 UTC](https://meta.discourse.org/t/can-a-plugin-auto-create-a-topic-after-create-of-a-category/177698/3 "2021-02-01T03:21:44Z")

</div>

There is a `DiscourseEvent` called `category_created`.

> <https://github.com/discourse/discourse/blob/184cd766acbda5a99285dfc1a8e65d256bde965a/app/models/category.rb#L91>

> <https://github.com/discourse/discourse/blob/184cd766acbda5a99285dfc1a8e65d256bde965a/app/models/category.rb#L840-L849>

You’d want to tie into that event and follow this example:

> <https://github.com/discourse/discourse-github/blob/d40c7728b8f9a1bb471c323b60afff331191cfb4/plugin.rb#L31-L36>

Hope that helps!

---

<div class="post-metadata">

### Author: ![frank.manuel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frank.manuel/32/203348_2.png) [@frank.manuel](https://meta.discourse.org/u/frank.manuel)
#### Post date: [2 februari 2021 om 08:14 UTC](https://meta.discourse.org/t/can-a-plugin-auto-create-a-topic-after-create-of-a-category/177698/4 "2021-02-02T08:14:04Z")

</div>

This is exactly what I needed! I just _KNEW_ there had to be an event I could catch, I just couldn’t find it. Many thanks!
