Assigns a badge to site members.
The assignMembers()
function returns a Promise
that resolves when the specified badge is assigned to the specified members.
The badgeId
parameter must be an ID from your site's Members/Badges
collection.
Typically, you retrieve the ID from the collection using a query or through a dataset.
ID of the badge to assign the members to.
IDs of the members to assign to the badge.
Creates a badge.
The createBadge()
function returns a Promise
that resolves to the newly created badge.
New badges do not have any badge permissions by default. You can set badge permissions from the Badges page in the Dashboard.
If backgroundColor
or textColor
are not specified, they default to "#796EFF"
(purple) and "#FFFFFF"
(white) respectively.
Settings for the new badge.
Deletes a badge.
The deleteBadge()
function returns a Promise that resolves when
the specified badge is deleted.
The badgeId
parameter must be an ID from your site's Members/Badges
collection.
Typically, you retrieve the ID from the collection using a query or through a dataset.
ID of the badge to delete.
Lists the badges assigned to each of the specified site members.
The listMemberBadges()
function returns a Promise that resolves to a
list of badge IDs associated with each of the specified members.
List of member IDs to list badges for.
Lists the IDs of all members assigned to a badge.
The listMembers()
function returns a Promise that resolves
to a list of member IDs assigned to the specified badge.
ID of the badge to list members of.
Removes site members from an assigned badge.
The removeMembers()
function returns a Promise that resolves
when the specified members are removed as holders of the specified badge.
The badgeId
parameter must be an ID from your site's Members/Badges
collection.
Typically, you retrieve the ID from the collection using a query or through a dataset.
function removeMembers(
badgeId: string,
memberIds: Array<string>,
): Promise<void>;
ID of the badge to remove the members from.
IDs of the members to remove from the badge.
import { Permissions, webMethod } from "wix-web-module";
import { badges } from "wix-members-backend";
export const myRemoveMembersFunction = webMethod(Permissions.Anyone, () => {
const badgeId = "3fcaacc0-a3a7-464f-9ba9-f211bdcec9fc";
const memberIds = [
"efab296e-2687-4751-9956-ee73200dd4bb",
"3403e13b-8826-4af6-aa19-18784bb84a8e",
"28d35f86-6694-4455-9dff-aff5d450b482",
];
return badges
.removeMembers(badgeId, memberIds)
.then(() => {
console.log("Members removed from badge");
})
.catch((error) => {
console.error(error);
});
});