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 for membershipOptions
parameter will default to member
.
member
- 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 the roleId
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 include firstCreated
, lastCreated
. The firstCreated
sort option will be specified by default if it isn't specified. When a keyword is provided, leading to a list sorted by search rank.
To query community banned members, only the 'Admin' role is currently allowed, while 'Moderators' and 'Users' are not allowed to query community banned members.
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.
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)
To search for community members, users can call the relevant method and provide the desired keyword, roles and membership options parameters. For example, 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.
If no keyword is supplied, the list of users for the specified community will be sorted by the date they joined.
To search for community members with certain criteria, the following parameters are used:
keyword
: allows users to specify the keyword to search for. The result contain members with either matching displayName
or userId
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 for membershipOptions
parameter will default to member
.
member
- 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 the roleId
of the custom role to filter members by this role.
To query community banned members, only the 'Admin' role is currently allowed, while 'Moderators' and 'Users' are not allowed to query community banned members.