# Creating discourse user group with code

**URL:** https://meta.discourse.org/t/creating-discourse-user-group-with-code/70228
**Category:** Development
**Created:** [September 17, 2017, 5:53pm UTC](https://meta.discourse.org/t/creating-discourse-user-group-with-code/70228 "2017-09-17T17:53:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sudaraka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sudaraka/32/68401_2.png) [@Sudaraka](https://meta.discourse.org/u/Sudaraka)
#### Post date: [September 17, 2017, 5:53pm UTC](https://meta.discourse.org/t/creating-discourse-user-group-with-code/70228/1 "2017-09-17T17:53:06Z")

</div>

I need to create a discourse user group with my plugin. I used the below code and its not working. Any idea why its not working ? Thankyou

```
default_group = Group.new(
        name: 'Dumy',
        visibility_level: Group.visibility_levels[:public],
        primary_group: true,
        title: 'Dumy',
        flair_url: 'https://dumy.com/public/images/oc-logo-icon.svg',
        bio_raw: 'Dumy wording.',
        full_name: 'dummy'
      )
default_group.save!

```

I referred to the code used in [patreon plugin](https://github.com/discourse/discourse-patreon/blob/master/lib/seed.rb)

---

<div class="post-metadata">

### Author: ![Sudaraka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sudaraka/32/68401_2.png) [@Sudaraka](https://meta.discourse.org/u/Sudaraka)
#### Post date: [September 18, 2017, 3:59am UTC](https://meta.discourse.org/t/creating-discourse-user-group-with-code/70228/2 "2017-09-18T03:59:34Z")

</div>

Thank you @riking for fixing the link

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [October 6, 2017, 4:51pm UTC](https://meta.discourse.org/t/creating-discourse-user-group-with-code/70228/3 "2017-10-06T16:51:22Z")

</div>

Are you seeing any errors in `/logs`? Can you link to the relevant plugin code if it’s publicly available on GitHub?

---

<div class="post-metadata">

### Author: ![Sudaraka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sudaraka/32/68401_2.png) [@Sudaraka](https://meta.discourse.org/u/Sudaraka)
#### Post date: [October 7, 2017, 1:34pm UTC](https://meta.discourse.org/t/creating-discourse-user-group-with-code/70228/4 "2017-10-07T13:34:45Z")

</div>

Hi @techAPJ,  
I’m not seeing any errors on my logs. This is the repo of my plugin

[https://github.com/sudaraka94/opencollective-plugin](https://github.com/sudaraka94/opencollective-plugin)

I was adding the feature in the branch `user-profile-details`

> <https://github.com/sudaraka94/discourse-opencollective-integration/blob/813e83ae3f859a95acf2404ebe83ace385681fe8/plugin.rb#L57>
