How do I add a user to a group

I wrote a hook that sends me a mail when the user is registered (via postCreateUser). I need to add it immediatily to an existing group. In the documentation, I was not able to find classes or examples to implement this, or not undersanding, how it's make. Please help.

Inject OCP\IGroupManager to your HooksHandler class and use it for your goal. Read the application development documentation first. You will use DI Container to inject group manager:

Thank you! This interface OCP\IGroupManager ( only allows me to learn through the hook, when the user was added to the group. But I need a command with which I can add a user to the group. I can't find it's method in IGroupManager. :frowning:

First, get the group with get function of GroupManager. After that use addMember function of the Group. Here is how OCC Group AddMember command work.

Great!!!! Thank you very much, I'm understend, try, and now all works, like as I expected! :slight_smile: