Automatically create users from http header Bit of an awkward one.

The client wants a system where they send us a link e.g. mycraftsite.com?userid=abc123 and from there we need to populate the user table.

I am new to craft but I am assuming the correct way is to use a plugin, grab the header data and somehow insert it using a hook, but I don't see any available for before the site renders.

Can anyone help point me in the right direction?
You would most likely want to add a controller to your custom plugin, with an 'action' method designed to handle the url request and generate a user; using 'post' or 'get' to pass parameters to the controller action.

In the controller action, you can access your parameters using:

$username = craft()-&gt;request-&gt;getParam('username');


You can then populate a new User Model using the passed params and save the model.

$user = new UserModel();

$user-&gt;username   = $username;
$user-&gt;email      = $email;
$user-&gt;firstName  = $firstName;
$user-&gt;lastName   = $lastName;
$user-&gt;getContent()-&gt;setAttributes([ 
    'customField' =&gt; $customFieldValue
]);

craft()-&gt;users-&gt;saveUser($user);

// We now have a user Id, so assign user to a group
craft()-&gt;userGroups-&gt;assignUserToGroups($user-&gt;id, $groupId);

// or to multiple groups
//craft()-&gt;userGroups-&gt;assignUserToGroups($user-&gt;id, [$groupId, $otherGroupId]);


However, by default, controller actions are only accessible to logged-in users. If you want to allow anonymous access you would need to specifically allow it using the $allowAnonymous property. This definitely introduces some security issues however, so proceed with caution. For example: definitely do not just assign user group(s) blindly from passed parameters or someone might be able to give themselves admin access!