Query Community Members
To retrieve a list of community members, users can call the relevant method and provide the desired membership options and sorting parameters. For example, they may choose to sort the list of members by name or by date created, or they may specify certain membership options, such as only retrieving members who are not banned. The result of the method will always return as Live collection.
To query community members with certain criteria, the following parameters are used:
membershipOptions
: allows users to filter the results based on the membership status of community members. Passing an empty option or not passing and option set formembershipOptions
parameter will default tomember
.none
- only non-members will be included in the resultsmember
- will filter out all banned members and only include unbanned members.ban
- will only include banned members in the results.
roles
: allows users to query for members with default moderator roles by using "channel-moderator" or "community-moderator" as the value. At this moment, we do not have a way to query for member-only roles. For custom roles assigned to members, users can pass in theroleId
of the custom role to filter members by this role.sortBy
: allows users to specify the sorting method for the returned collection. The possible values includefirstCreated
,lastCreated
, anddisplayName
.
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.
iOS
Android
JavaScript
TypeScript
Flutter
Passing an empty option set for
membershipOptions
parameter will default to .member
.Below is the sample code to get a list of community members. This method will return a
LiveCollection
instance. Version 6
Beta(v0.0.1)
Last modified 29d ago