Back

How do we edit team member roles? Beyond delete and add again.

  • 0
  • Teams
Business of Technology
8 Jun, 2023, 16:15

We figured out teams, but the team members' roles don't appear to have an edit feature. Short of delete and add again, is this something I should add a feature request for or did I miss how to perform the task?

TL;DR
You can edit team member roles in two ways: 1. From the client side: Any team member with the `owner` role can use the `updateMembershipRoles` function to update the roles of other members. For example, you can add a `subscriber` role to a member by using the `updateMembershipRoles` function and the spread operator to keep the member's previous roles. 2. From the server side: You can also use the `updateMembershipRoles` function from a server side SDK. In this case, you don't need a member with the `owner` role as you can run it as an App user using
Binyamin
8 Jun, 2023, 16:20

You have two ways in which you'll be able to update memeber roles.

  1. From Client side any member that have the owner on that team can update any other user roles, by using the updateMembershipRoles function. For example:
TypeScript
const member = await teams.getMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');

// Adding subscriber role.
teams.updateMembershipRoles('[TEAM_ID]', '[MEMBERSHIP_ID]', [...member.roles, 'subscriber']);

By using the spread ... operator you're making sure you'll keep the user previous roles.

  1. From a Server side SDK, using the same function and syntax. But, now you don't need any member with owner role, as you run it as App user using an API key.
Binyamin
8 Jun, 2023, 16:20

Hope that's making sense.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more