How to assign role to a custom registration form?

One way of doing it is, when you are submitting the registration form, define a value for the ‘role’ and then pass it with wp_insert_user Codex.

Like this:

$fields_user = get_fields_user(); //get the values from the form and put them in an array.
$fields_user['role'] = 'participant'; //define a value for the key 'role'
$user_id = wp_insert_user($fields_user); //get all the info and register it with the wp_insert_user

But that role has to be already created in the admin