Automatically update roles

Good day all,

I am wondering what is the most efficient way to automatically assign a new roles to new or exisiting users.
Here is some context using the library management app (tutorial)
Instead of creating a library user doctype, I think it is more efficient to assign the role of library member to let’s say: students, guardian, instructor.

So how can I create a customization such that every students, guardian and instructor has by default the library_member role?

I understand I can do it on the Doctype itself of these people. But if I do that, it won’t keep at next update.

Looking forward for hints / ideas / examples on how to do that.

Thanks in advance.

Still looking for ideas :wink: . Thanks.

You can try using Role Profile. A Role Profile will have some pre-existing roles linked to it. You can just assign he role profile of a student to the User and the relevant roles will be applied accordingly.
Check the following link to know more about the same:
https://erpnext.com/docs/user/manual/en/setting-up/users-and-permissions/role-and-role-profile

Hope this helps!