Unassigns a role from group members.
Note: This function is only relevant for site admins, and group members with group admin permissions.
The unassignRole()
function returns a Promise that resolves to the unassigned role after it has successfully been unassigned. This function only applies
to admin roles. Using this function with member roles returns an error.
function unassignRole(
identifiers: Identifiers,
role: string,
options: Options,
): Promise<Role>;
Group ID and member IDs.
Group member role to unassign.
"ADMIN"
: Group admin.Authorization options.
import { Permissions, webMethod } from "wix-web-module";
import { roles } from "wix-groups-backend";
// Sample identifiers value:
// {
// memberIds: ['7fe8e9e1-d050-4c86-9684-e7f231600a34'],
// groupId: '0261a737-2361-4468-a3b1-5ec2b0667836.'
// }
//
// Sample role value:
// 'ADMIN'
//
// Sample options value:
// {
// suppressAuth: true
// }
export const unassignRole = webMethod(
Permissions.Anyone,
async (identifiers, role, options) => {
try {
const response = await roles.unassignRole(identifiers, role, options);
console.log(response);
} catch (error) {
console.error(error);
}
},
);
/* Promise resolves to:
* role: "MEMBER"
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.