Hi again,
After some tests after the code change now it's having another problem.
When you enroll a user to a course and bet back there to enroll other again the previous enrolled users are unenroled from it making the course with no enrolles. this line on the previous file
//$DB->delete_records('mnetservice_enrol_enrolments',array('hostid'=>$mnethostid));
$DB->delete_records('mnetservice_enrol_enrolments',array('hostid'=>$mnethostid, 'remotecourseid'=>$remotecourseid));
I hope to get nice news,TIA