You would want to do an event script on user.register.post.post_process
there are two key objects you'll want to get in your testing to see how everything is processed, event.request, and event.response
You can write a script that simply says
This will dump the objects into your log so you can look through them and see the structure.
In your script, first you'll want to check for
event.response.success === true
because you only want to set this for successful registrations.
If you're using email confirmation, then you also want to check if
event.request.payload.code exists. If it does then that indicates that this POST was a user confirming their account
From there you just use platform.api to assign the role. You'll want to familiarize yourself with the system/user response object.
Specifically, the related field user_to_app_to_role_by_user_id (
A new user should not have anything in this field.
You can use platform.api.patch to update the user object role assignment.
In this example, my newly created user's id is 4, and the app and role ids I want to user are both 1.