I am trying to add role field in the registration form. I want to show the roles in system context. I have added the following code in signup_form.php
$systemcontext = context_system::instance();
$roles=get_roles_used_in_context($systemcontext);
$mform->addElement('select', 'roles', get_string('roles'), $roles);
Now the role field is appearing, but has no values in it. How can I get the roles in the system context? Also on submitting the form I have to assign the selected role to the user in system context. Please help