Adding multiple roles for website users


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.

I could achieve this using hooks.

doc_events = {
	"Patient": {
		"after_insert": "custom_4cs.utils.add_role_customer"


def add_role_customer(doc, method):
		if frappe.db.exists ('User',
			user = frappe.get_doc('User',
			user.flags.ignore_permissions = True
1 Like