diff --git a/enrol/manual/classes/enrol_users_form.php b/enrol/manual/classes/enrol_users_form.php
index <HASH>..<HASH> 100644
--- a/enrol/manual/classes/enrol_users_form.php
+++ b/enrol/manual/classes/enrol_users_form.php
@@ -123,9 +123,7 @@ class enrol_manual_enrol_users_form extends moodleform {
 
         $roles = get_assignable_roles($context);
         $mform->addElement('select', 'roletoassign', get_string('assignrole', 'enrol_manual'), $roles);
-        $keys = array_keys($roles);
-        $defaultrole = end($keys);
-        $mform->setDefault('roletoassign', $defaultrole);
+        $mform->setDefault('roletoassign', $instance->roleid);
 
         $mform->addAdvancedStatusElement('main');
MDL-<I> enrol_manual: Fixes not working default role