Briefly, these are your main options:
Write a custom user registration component
Write a User Plugin that will handle the usergroup of the registered users
Use 3rd party Form extensions which integrate with JUsers and create your custom form(s)
A few form extensions that work well for this use case:
RSForm pro with its JUser/Registration plugin,
(This answer has been updated from the original which suggested hacking Joomla code, to this much better solution proposed in the comment below - thanks to @Irata!)
Joomla includes the custom fields by means of a plugin which is triggered on onContentPrepareForm. This solution involves writing a second plugin, also triggered on onContentPrepareForm, which ...
Several pointers/recommendations regarding your resolving code for you and future researchers.
implode() has a default "glue" of an empty space. PHP Manual When you want to join array elements into a string with no delimiter, you can omit the glue parameter and solely provide the array.
$nMail = implode($arr);
$nMail = implode([$myobject,'@domain....