Plugin support for creating groups

Hello, I’m totally new to discourse and have tried to get myself stuck in to making a plugin straight away.

Starting to work my around, but can anyone tell me what the best method would be for creating a new group within my plugin?

The end goal is to automatically add invitees to groups, created for each individual inviter.

Would it be best to directly call the GroupsController class or do some sort of post via the js?

This feature already available while sending invitations.

Thanks for the fast reply!

Yes it is, but only to existing groups.

I want invitees to automatically be added to a newly created group referencing the inviter (if it’s the inviter’s first invite).

I want this to be automatic, non-optional, separate from the existing optional functionality.

You can call GroupsController methods directly from your plugin. Else you can copy codes from save_group method from https://github.com/discourse/discourse/blob/master/app/controllers/admin/groups_controller.rb#L51.

It (Discourse API) will be useful if your creating group from another separate application.