I have added some user roles that have custom fields that can be filled when editing the user after creation but I want them to be assigned on user creation (Add New).
<tr>
<th><label for="area"><?php _e('Area', 'area'); ?></label></th>
<td>
<?php wp_dropdown_categories([
'name' => 'force_area',
'taxonomy' => 'area',
'show_option_none' => __('— Select —', 'pcc-paro'),
'option_none_value' => '0',
'selected' => $area ? $area->term_id : 0,
'required' => true,
]); ?>
</td>
</tr>
To add user custom fields on user profile creation, you need to use
user_new_formhook.The following hooked function include your field code, with some modifications:
The code example (define the desire user role at the beginning of the function):
Code goes in functions.php file of your child theme (or in a plugin). Tested and works.