Hello everyone,
I need to change user permission or role after they are approved by admin, I prefer to run a server script on update user to check the user and change user permissions.
How can I do that?
Thanks in advance.
Hello everyone,
I need to change user permission or role after they are approved by admin, I prefer to run a server script on update user to check the user and change user permissions.
How can I do that?
Thanks in advance.
For the first part, checking user permission in server script:
users = frappe.db.get_list('User')
for i in users:
has_role = frappe.get_all('Has Role', filters=dict(parent=i.name))
#print(i.name, has_role)
I don’t have anything for changing user permissions atm.
To add a user role:
user = frappe.get_doc(“User”, frappe.session.user)
user.append(“roles”, {“role”:”Employee”})
user.save()
frappe.db.commit()
Hello guys
what’s the updated version for this solution?
frappe.db.commit() throws error
“module doesn’t have attribute commit” in server script
and the new roles are not saved in the database