Community Membership
You can get a list of community members through AmityCommunityParticipation
class. It exposes getMembers
method which accepts membershipOptions
and sortBy
parameters.
The
membershipOptions
parameter can have the following filters:.none
- filters all non-members in a community.member
- filters all unbanned members in a community.ban
- filters all banned members in a community
The
roles
parameter filter members by specific role.To query members with the default moderator roles assigned, you can use
'channel-moderator'
,'community-moderator
'. At this moment, we do not have a way to query for member-only roles. However, if you have assigned a custom role to a member in the community, you can pass in theroleId
of the custom role to filter members by this role.
Please note that you can only assign custom roles to a member in a community via the SDK. This feature is not yet available in the Amity Console.
If you assign a custom role to a user via the Amity console, the role will only be applied at the user level and not at the community level, and if you try to query for a member with this custom role, no results will be returned.
sortBy
- sorting method to arrange the returned collection. The possible values are: (seeCommunitySortingMethod
)'firstCreated'
'lastCreated'
'displayName'
search
- query string
Passing an empty option set for membershipOptions
parameter will default to .member
. This means that the result for both sample code below is the same.
Same class provides addMembers(_:)
and removeMembers(_:)
which can be used to add or remove users from the community.
Last updated