api: create user account for student
Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
diff --git a/erpnext/education/api.py b/erpnext/education/api.py
index 30d5588..b75635e 100644
--- a/erpnext/education/api.py
+++ b/erpnext/education/api.py
@@ -38,7 +38,18 @@
program_enrollment.student = student.name
program_enrollment.student_name = student.title
program_enrollment.program = frappe.db.get_value("Student Applicant", source_name, "program")
- frappe.publish_realtime('enroll_student_progress', {"progress": [4, 4]}, user=frappe.session.user)
+ frappe.publish_realtime('enroll_student_progress', {"progress": [4, 4]}, user=frappe.session.user)
+ student_user = frappe.get_doc({
+ 'doctype':'User',
+ 'first_name': student.first_name,
+ 'email': student.student_email_id,
+ 'send_welcome_email': 1,
+ 'user_type': 'Website User'
+ })
+ student_user.add_roles("Student", "LMS User")
+ student_user.save()
+ update_password_link = student_user.reset_password()
+ print(update_password_link)
return program_enrollment