Register a user to a specific group I'm trying to register a user from the front-end and assign them to a specific group. I know that via control panel I can set a default user group, but there is a registration instance where I need the registrant to be assigned to a different group.

I tried this to no avail...

&lt;input type="hidden" name="groups" value="4"&gt;
You can only do this with custom PHP otherwise this is going to be a high security risk. Imagine someone just changes your HTML and inserts a different group id: everyone could just join the group he/she likes.

Instead you can Enhancing a Craft CMS 3 Website with a Custom Module - there is already a default one and insert an event to do this by yourself but you need to be careful. I wouldn't trust user input in that case too much.

Event::on(
    Elements::class,
    Elements::EVENT_AFTER_SAVE_ELEMENT,
    function(ElementEvent $event){
        if(\get_class($event-&gt;element) === User::class){
            $joinSpecialGroup = (bool)Craft::$app-&gt;getRequest()-&gt;getBodyParam('joinSpecialGroup');
            if($joinSpecialGroup === true){
                Craft::$app-&gt;getUsers()-&gt;assignUserToGroups($event-&gt;element-&gt;id, [4]);
            }
        }
    }
);


Note: I woulnd't call the property joinSpecialGroup - it is just for demonstration