Hi,
I have configured my ERPNext instance for Healthcare domain. Default website role in portal settings is “Patient”, But I would also like them to be customers for letting them make purchases online and track orders, invoices etc. How can I add “Customer” role to the website users automatically along with “Patient”.
You can do this using the Roles stated in the user settings.
you can either create a role profile (best practice) or select each role you need for each user.
and these roles have permissions that you can check in permission manager
Thank you. I want this to happen on user sign-up programmatically. I don’t want this to be done manually.
Update:
I could achieve this using hooks.
doc_events = {
"Patient": {
"after_insert": "custom_4cs.utils.add_role_customer"
}
}
In utils.py
def add_role_customer(doc, method):
if doc.email:
if frappe.db.exists ('User', doc.email):
user = frappe.get_doc('User', doc.email)
user.flags.ignore_permissions = True
user.add_roles('Customer')
1 Like