# How to create categories from plugin

**URL:** https://meta.discourse.org/t/how-to-create-categories-from-plugin/52443
**Category:** Development
**Created:** [November 3, 2016, 2:27pm UTC](https://meta.discourse.org/t/how-to-create-categories-from-plugin/52443 "2016-11-03T14:27:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [November 3, 2016, 2:27pm UTC](https://meta.discourse.org/t/how-to-create-categories-from-plugin/52443/1 "2016-11-03T14:27:36Z")

</div>

I am developing new [community-hub](https://github.com/vinkas0/discourse-community-hub) plugin for discourse where any registered users can create categories for their group / community. So the plugin should create categories itself in some criteria.

Can anyone help me to do this programmatically via plugin. And I welcome contributors for my new plugin 🙂

---

<div class="post-metadata">

### Author: ![spirobel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spirobel/32/170908_2.png) [@spirobel](https://meta.discourse.org/u/spirobel)
#### Post date: [July 15, 2020, 11:16am UTC](https://meta.discourse.org/t/how-to-create-categories-from-plugin/52443/2 "2020-07-15T11:16:49Z")

</div>

I would also be interested to know how to programmatically create Categories!  
EDIT: Okay, figured it out. Put something like this in your plugin.rb

```ruby
  @cat =Category.new({"user_id"=> 1 ,"name"=>"bla", "color"=>"0088CC", "text_color"=>"FFFFFF", "permissions"=>{"everyone"=>"1"},"required_tag_group_name"=>"", "topic_featured_link_allowed"=>"true", "search_priority"=>"0"})
  @cat.save
  puts @cat.errors.inspect

```
