---
schema_version: "1"
id: a7096f196d9f44e6c83e71587faa156068bad38c6db18929a5db279a99066a6d
title: ChatterUsers Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_ConnectAPI_ChatterUsers_static_methods.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b5f09bebe717e58faf15fb0adad0bf77bf2b5a1493d3ff341c8e854bc27febd8
description: Access information about users, such as activity, followers, subscriptions, files, and groups.These methods are for ChatterUsers. All methods are static.Export Chatter-related user activity, such as bookmarks, topic endorsements, and votes.Follow a user or record. Get the default Chatter settings for a user. Get the first page of followers for a user.Get a page of followers for a user. Get the first page of users and records that a user follows.Get a page of users and records that a user follows.Get a page with the specified number of users and records that a user follows.Get the first page of records, filtered by key prefix, that a user follows.Get a page of records, filtered by key prefix, that a user follows.Get a page with the specified number of records, filtered by key prefix, that a user follows.Get a user’s reputation.Get information about a user.Get information about a list of users.Get a user’s groups.Get a page of a user’s groups. Get the first page of users.Get a page of users. Start a job to purge Chatter-related user activity, such as bookmarks, topic endorsements, and votes.Get the user’s groups that match the search criteria.Get a page of a user’s groups that match the search criteria.Get the first page of users that match the search criteria.Get a page of users that match the search criteria. Get a page of users that match the search criteria. Update the default Chatter settings for a user.Update the About Me section for a user.These test methods are for ChatterUsers. All methods are static.Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.These methods for ChatterUsers are retired.Delete a user’s photo.Get the groups that a user is a member of. Get a page of groups that a user is a member of.Get a user’s photo. Get the user’s groups that match the search criteria.Get a page of a user’s groups that match the search criteria.Set an uploaded file as a user’s photo. Set a file that hasn’t been uploaded as the user’s photo.Set and crop an uploaded file as a user’s photo.Set and crop a file that hasn’t been uploaded as a user’s photo.
---
# ChatterUsers Class

Access information about users, such as activity, followers, subscriptions, files, and groups.

## Namespace

[ConnectApi](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_connect_api.htm "The ConnectApi namespace (also called Connect in Apex) provides classes for accessing the same data available in Connect REST API. Use Connect in Apex to create custom experiences in Salesforce.")

## ChatterUsers Methods

These methods are for ChatterUsers. All methods are static.

All methods in this class require Chatter and are subject to the per user, per namespace, per hour rate limit.

- **[exportUserActivities(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_exportUserActivities_1)**  
    Export Chatter-related user activity, such as bookmarks, topic endorsements, and votes.
- **[follow(communityId, userId, subjectId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_follow)**  
    Follow a user or record.
- **[getChatterSettings(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getChatterSettings)**  
    Get the default Chatter settings for a user.
- **[getFollowers(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowers)**  
    Get the first page of followers for a user.
- **[getFollowers(communityId, userId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowers_2)**  
    Get a page of followers for a user.
- **[getFollowings(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowings)**  
    Get the first page of users and records that a user follows.
- **[getFollowings(communityId, userId, pageParam)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowings_2)**  
    Get a page of users and records that a user follows.
- **[getFollowings(communityId, userId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowings_3)**  
    Get a page with the specified number of users and records that a user follows.
- **[getFollowings(communityId, userId, filterType)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowings_4)**  
    Get the first page of records, filtered by key prefix, that a user follows.
- **[getFollowings(communityId, userId, filterType, pageParam)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowings_5)**  
    Get a page of records, filtered by key prefix, that a user follows.
- **[getFollowings(communityId, userId, filterType, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getFollowings_6)**  
    Get a page with the specified number of records, filtered by key prefix, that a user follows.
- **[getReputation(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getReputation_1)**  
    Get a user’s reputation.
- **[getUser(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getUser)**  
    Get information about a user.
- **[getUserBatch(communityId, userIds)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getUserBatch)**  
    Get information about a list of users.
- **[getUserGroups(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getGroups_3)**  
    Get a user’s groups.
- **[getUserGroups(communityId, userId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getGroups_4)**  
    Get a page of a user’s groups.
- **[getUsers(communityId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getUsers)**  
    Get the first page of users.
- **[getUsers(communityId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getUsers_2)**  
    Get a page of users.
- **[purgeUserActivities(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_purgeUserActivities_1)**  
    Start a job to purge Chatter-related user activity, such as bookmarks, topic endorsements, and votes.
- **[searchUserGroupDetails(communityId, userId, q)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectApi_ChatterUsers_searchUserGroups_3)**  
    Get the user’s groups that match the search criteria.
- **[searchUserGroupDetails(communityId, userId, q, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectApi_ChatterUsers_searchUserGroups_4)**  
    Get a page of a user’s groups that match the search criteria.
- **[searchUsers(communityId, q)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_searchUsers)**  
    Get the first page of users that match the search criteria.
- **[searchUsers(communityId, q, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_searchUsers_2)**  
    Get a page of users that match the search criteria.
- **[searchUsers(communityId, q, searchContextId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_searchUsers_3)**  
    Get a page of users that match the search criteria.
- **[updateChatterSettings(communityId, userId, defaultGroupEmailFrequency)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_updateChatterSettings)**  
    Update the default Chatter settings for a user.
- **[updateUser(communityId, userId, userInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_updateUser)**  
    Update the About Me section for a user.

### exportUserActivities(communityId, userId)

Export Chatter-related user activity, such as bookmarks, topic endorsements, and votes.

#### API Version

42.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserActivitiesJob exportUserActivities(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID of the user.

#### Return Value

Type: [ConnectApi.UserActivitiesJob](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_activities_job.htm#apex_connectapi_output_user_activities_job "User activities job.")

#### Usage

The following activities can be exported.

- Bookmark—User bookmarked a post.
- ChatterActivity—Total counts of posts and comments made and likes and comments received for a user.
- ChatterLike—User liked a post or comment.
- Comment—User commented on a post.
- CompanyVerify—User verified comment.
- DownVote—User downvoted a post or comment.
- FeedEntityRead—User read a post.
- FeedRead—User read a feed.
- Mute—User muted a post.
- Post—User made a post.
- TopicEndorsement—User endorsed another user on a topic or received endorsement on a topic.
- UpVote—User upvoted a post or comment.

### follow(communityId, userId, subjectId)

Follow a user or record.

#### API Version

28.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.Subscription follow(String communityId, String userId, String subjectId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

subjectId

Type: String

ID of the user or record to follow.

#### Return Value

Type: [ConnectApi.​Subscription](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_subscription.htm "Subscription.")

#### Example

ChatterUsers.ConnectApi.Subscription subscriptionToRecord = ConnectApi.ChatterUsers.follow(null, 'me', '001RR000002G4Y0');

#### Usage

This method creates an EntitySubscription record, which requires certain permissions. See the Usage section of the [EntitySubscription](https://developer.salesforce.com/docs/atlas.en-us.264.0.object_reference.meta/object_reference/sforce_api_objects_entitysubscription.htm) object for more information.

#### See Also

- [_Apex Developer Guide_: Unfollow a Record](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectapi_examples_unfollow_record.htm "Apex Developer Guide: Unfollow a Record - HTML (New Window)")

### getChatterSettings(communityId, userId)

Get the default Chatter settings for a user.

#### API Version

28.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserChatterSettings getChatterSettings(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

#### Return Value

Type: [ConnectApi.​User​​ChatterSettings](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_chatter_settings.htm "User’s global Chatter settings.")

### getFollowers(communityId, userId)

Get the first page of followers for a user.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowerPage getFollowers(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

#### Return Value

Type: [ConnectApi.​FollowerPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_Follower_Page.htm "Page of followers.")

### getFollowers(communityId, userId, pageParam, pageSize)

Get a page of followers for a user.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowerPage getFollowers(String communityId, String userId, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.​FollowerPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_Follower_Page.htm "Page of followers.")

### getFollowings(communityId, userId)

Get the first page of users and records that a user follows.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowingPage getFollowings(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

#### Return Value

Type: [ConnectApi.​FollowingPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_following_page.htm "Page of following subscriptions.")

### getFollowings(communityId, userId, pageParam)

Get a page of users and records that a user follows.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowingPage getFollowings(String communityId, String userId, Integer pageParam)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

#### Return Value

Type: [ConnectApi.​FollowingPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_following_page.htm "Page of following subscriptions.")

### getFollowings(communityId, userId, pageParam, pageSize)

Get a page with the specified number of users and records that a user follows.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowingPage getFollowings(String communityId, String userId, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.​FollowingPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_following_page.htm "Page of following subscriptions.")

### getFollowings(communityId, userId, filterType)

Get the first page of records, filtered by key prefix, that a user follows.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowingPage getFollowings(String communityId, String userId, String filterType)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

filterType

Type: String

Specifies the key prefix to filter the type of objects returned. A key prefix is the first three characters of the object ID, which specifies the object type. For example, User objects have a prefix of 005 and Group objects have a prefix of 0F9.

#### Return Value

Type: [ConnectApi.​FollowingPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_following_page.htm "Page of following subscriptions.")

### getFollowings(communityId, userId, filterType, pageParam)

Get a page of records, filtered by key prefix, that a user follows.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowingPage getFollowings(String communityId, String userId, String filterType, Integer pageParam)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

filterType

Type: String

Specifies the key prefix to filter the type of objects returned. A key prefix is the first three characters of the object ID, which specifies the object type. For example, User objects have a prefix of 005 and Group objects have a prefix of 0F9.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

#### Return Value

Type: [ConnectApi.​FollowingPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_following_page.htm "Page of following subscriptions.")

### getFollowings(communityId, userId, filterType, pageParam, pageSize)

Get a page with the specified number of records, filtered by key prefix, that a user follows.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.FollowingPage getFollowings(String communityId, String userId, String filterType, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

filterType

Type: String

Specifies the key prefix to filter the type of objects returned. A key prefix is the first three characters of the object ID, which specifies the object type. For example, User objects have a prefix of 005 and Group objects have a prefix of 0F9.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.​FollowingPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_following_page.htm "Page of following subscriptions.")

### getReputation(communityId, userId)

Get a user’s reputation.

#### API Version

32.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.Reputation getReputation(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID of the user.

#### Return Value

Type: [ConnectApi.Reputation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_reputation.htm#apex_connectapi_output_reputation "Reputation for a user.")

### getUser(communityId, userId)

Get information about a user.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserSummary getUser(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

#### Return Value

Type: [ConnectApi.UserDetail](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_detail.htm#apex_connectapi_output_user_detail "Details about a user in an org.")

#### Usage

If the user is external, the properties that the ConnectApi.UserDetail output class shares with the [ConnectApi.UserSummary](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_summary.htm#apex_connectapi_output_user_summary "User summary.") output class can have non-null values. Other properties are always null.

### getUserBatch(communityId, userIds)

Get information about a list of users.

#### API Version

31.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.BatchResult\[\] getUserBatch(String communityId, List<String\> userIds)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userIds

Type: [List](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_list.htm#apex_methods_system_list "Contains methods for the List collection type.")<String>

A list of up to 500 user IDs.

#### Return Value

Type: [ConnectApi.BatchResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_batch_result.htm "The result of an operation returned by a batch method.")\[\]

The ConnectApi.BatchResult.getResult() method returns a ConnectApi.User object and errors for users that didn’t load.

#### Example

// Get users in an organization.
ConnectApi.UserPage userPage = ConnectApi.ChatterUsers.getUsers(null);

// Create a list of user IDs.
List<String\> userList = new List<String\>();
for (ConnectApi.User user : userPage.users){
    userList.add(user.id); 
}

// Get info about all users in the list.
ConnectApi.BatchResult\[\] batchResults = ConnectApi.ChatterUsers.getUserBatch(null, userList);

for (ConnectApi.BatchResult batchResult : batchResults) {
    if (batchResult.isSuccess()) {
        // Operation was successful. 
        // Print each user's username.
        ConnectApi.UserDetail user;
        if(batchResult.getResult() instanceof ConnectApi.UserDetail) {
            user = (ConnectApi.UserDetail) batchResult.getResult();
        }
        System.debug('SUCCESS');
        System.debug(user.username);
    }
    else {
        // Operation failed. Print errors.
        System.debug('FAILURE');
        System.debug(batchResult.getErrorMessage());
    }
}

### getUserGroups(communityId, userId)

Get a user’s groups.

#### API Version

45.0

#### Available to Guest Users

45.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupDetailPage getUserGroups(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

#### Return Value

Type: [ConnectApi.UserGroupDetailPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_detail_collection.htm "A page of groups that a user is a member of.")

### getUserGroups(communityId, userId, pageParam, pageSize)

Get a page of a user’s groups.

#### API Version

45.0

#### Available to Guest Users

45.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupDetailPage getUserGroups(String communityId, String userId, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.UserGroupDetailPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_detail_collection.htm "A page of groups that a user is a member of.")

### getUsers(communityId)

Get the first page of users.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserPage getUsers(String communityId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

#### Return Value

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

### getUsers(communityId, pageParam, pageSize)

Get a page of users.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserPage getUsers(String communityId, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

### purgeUserActivities(communityId, userId)

Start a job to purge Chatter-related user activity, such as bookmarks, topic endorsements, and votes.

#### API Version

42.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserActivitiesJob purgeUserActivities(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID of the user.

#### Return Value

Type: [ConnectApi.UserActivitiesJob](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_activities_job.htm#apex_connectapi_output_user_activities_job "User activities job.")

#### Usage

The following activities can be purged with this method.

- Bookmark—User bookmarked a post.
- ChatterActivity—Total counts of posts and comments made and likes and comments received for a user.
- ChatterLike—User liked a post or comment.
- CompanyVerify—User verified comment.
- DownVote—User downvoted a post or comment.
- FeedEntityRead—User read a post.
- FeedRead—User read a feed.
- Mute—User muted a post.
- TopicEndorsement—User endorsed another user on a topic or received endorsement on a topic.
- UpVote—User upvoted a post or comment.

To delete a user’s posts and comments, use these methods, respectively.

- [deleteFeedElement(communityId, feedElementId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_deleteFeedElement_1 "Delete a feed element.")
- [deleteComment(communityId, commentId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_deleteComment "Delete a comment.")

### searchUserGroupDetails(communityId, userId, q)

Get the user’s groups that match the search criteria.

#### API Version

45.0

#### Available to Guest Users

45.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupDetailPage searchUserGroupDetails(String communityId, String userId, String q)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

#### Return Value

Type: [ConnectApi.UserGroupDetailPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_detail_collection.htm "A page of groups that a user is a member of.")

### searchUserGroupDetails(communityId, userId, q, pageParam, pageSize)

Get a page of a user’s groups that match the search criteria.

#### API Version

45.0

#### Available to Guest Users

45.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupDetailPage searchUserGroupDetails(String communityId, String userId, String q, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.UserGroupDetailPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_detail_collection.htm "A page of groups that a user is a member of.")

### searchUsers(communityId, q)

Get the first page of users that match the search criteria.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserPage searchUsers(String communityId, String q)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

#### Return Value

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

#### Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

#### See Also

- [setTestSearchUsers(communityId, q, result)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setTestSearchUsers "Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.")
- [_Apex Developer Guide_: Testing ConnectApi Code](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectAPI_TestingApex.htm "Apex Developer Guide: Testing ConnectApi Code - HTML (New Window)")

### searchUsers(communityId, q, pageParam, pageSize)

Get a page of users that match the search criteria.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserPage searchUsers(String communityId, String q, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

#### Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

#### See Also

- [setTestSearchUsers(communityId, q, pageParam, pageSize, result)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setTestSearchUsers_2 "Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.")
- [_Apex Developer Guide_: Testing ConnectApi Code](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectAPI_TestingApex.htm "Apex Developer Guide: Testing ConnectApi Code - HTML (New Window)")

### searchUsers(communityId, q, searchContextId, pageParam, pageSize)

Get a page of users that match the search criteria.

#### API Version

28.0

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserPage searchUsers(String communityId, String q, String searchContextId, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

searchContextId

Type: String

A feed item ID that filters search results for feed @mentions. More useful results are listed first. When you specify this argument, you cannot query more than 500 results and you cannot use wildcards in the search term.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

#### Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

#### See Also

- [setTestSearchUsers(communityId, q, searchContextId, pageParam, pageSize, result)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setTestSearchUsers_3 "Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.")
- [_Apex Developer Guide_: Testing ConnectApi Code](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectAPI_TestingApex.htm "Apex Developer Guide: Testing ConnectApi Code - HTML (New Window)")

### updateChatterSettings(communityId, userId, defaultGroupEmailFrequency)

Update the default Chatter settings for a user.

#### API Version

28.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserChatterSettings updateChatterSettings(String communityId, String userId, ConnectApi.GroupEmailFrequency defaultGroupEmailFrequency)

#### Parameters

**communityId**

Type: String

ID for an Experience Cloud site, internal, or null.

**userId**

Type: String

ID for the context user or the keyword me.

**defaultGroupEmailFrequency**

Type: [ConnectApi.​GroupEmail​Frequency](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/connectAPI_enums.htm#GroupEmailFreq_enum)

Frequency with which a user receives email. Values are:

- EachPost
- DailyDigest
- WeeklyDigest
- Never
- UseDefault

Don’t pass the value UseDefault for the defaultGroupEmailFrequency parameter because calling updateChatterSettings sets the default value.

#### Return Value

Type: [ConnectApi.​User​​ChatterSettings](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_chatter_settings.htm "User’s global Chatter settings.")

### updateUser(communityId, userId, userInput)

Update the About Me section for a user.

#### API Version

29.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserDetail updateUser(String communityId, String userId, ConnectApi.UserInput userInput)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

userInput

Type: [ConnectApi.UserInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_userInput.htm "Update a user’s About Me information.")

Specifies the updated information.

#### Return Value

Type: [ConnectApi.​User​Detail](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_detail.htm "Details about a user in an org.")

## ChatterUsers Test Methods

These test methods are for ChatterUsers. All methods are static.

For information about using these methods to test your ConnectApi code, see [Testing ConnectApi Code](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectAPI_TestingApex.htm).

- **[setTestSearchUsers(communityId, q, result)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setTestSearchUsers)**  
    Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.
- **[setTestSearchUsers(communityId, q, pageParam, pageSize, result)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setTestSearchUsers_2)**  
    Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.
- **[setTestSearchUsers(communityId, q, searchContextId, pageParam, pageSize, result)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setTestSearchUsers_3)**  
    Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.

### setTestSearchUsers(communityId, q, result)

Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.

#### API Version

28.0

#### Signature

public static Void setTestSearchUsers(String communityId, String q, ConnectApi.UserPage result)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

result

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

Object containing test data.

#### Return Value

Type: Void

#### See Also

- [searchUsers(communityId, q)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_searchUsers "Get the first page of users that match the search criteria.")
- [_Apex Developer Guide_: Testing ConnectApi Code](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectAPI_TestingApex.htm "Apex Developer Guide: Testing ConnectApi Code - HTML (New Window)")

### setTestSearchUsers(communityId, q, pageParam, pageSize, result)

Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.

#### API Version

28.0

#### Signature

public static Void setTestSearchUsers(String communityId, String q, Integer pageParam, Integer pageSize, ConnectApi.UserPage result)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

result

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

Object containing test data.

#### Return Value

Type: Void

#### See Also

- [searchUsers(communityId, q, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_searchUsers_2 "Get a page of users that match the search criteria.")
- [_Apex Developer Guide_: Testing ConnectApi Code](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectAPI_TestingApex.htm "Apex Developer Guide: Testing ConnectApi Code - HTML (New Window)")

### setTestSearchUsers(communityId, q, searchContextId, pageParam, pageSize, result)

Register a ConnectApi.UserPage object to be returned when the matching ConnectApi.searchUsers method is called in a test context. Use the method with the same parameters or you receive an exception.

#### API Version

28.0

#### Signature

public static Void setTestSearchUsers(String communityId, String q, String searchContextId, Integer pageParam, Integer pageSize, ConnectApi.UserPage result)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

searchContextId

Type: String

A feed item ID that filters search results for feed @mentions. More useful results are listed first. When you specify this argument, you cannot query more than 500 results and you cannot use wildcards in the search term.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

result

Type: [ConnectApi.UserPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_page.htm "Page of users.")

Object containing test data.

#### Return Value

Type: Void

#### See Also

- [searchUsers(communityId, q, searchContextId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_searchUsers_3 "Get a page of users that match the search criteria.")
- [_Apex Developer Guide_: Testing ConnectApi Code](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/connectAPI_TestingApex.htm "Apex Developer Guide: Testing ConnectApi Code - HTML (New Window)")

## Retired ChatterUsers Methods

These methods for ChatterUsers are retired.

All methods in this class require Chatter and are subject to the per user, per namespace, per hour rate limit.

- **[deletePhoto(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_deletePhoto)**  
    Delete a user’s photo.
- **[getGroups(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getGroups)**  
    Get the groups that a user is a member of.
- **[getGroups(communityId, userId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getGroups_2)**  
    Get a page of groups that a user is a member of.
- **[getPhoto(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_getPhoto)**  
    Get a user’s photo.
- **[searchUserGroups(communityId, userId, q)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectApi_ChatterUsers_searchUserGroups)**  
    Get the user’s groups that match the search criteria.
- **[searchUserGroups(communityId, userId, q, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectApi_ChatterUsers_searchUserGroups_2)**  
    Get a page of a user’s groups that match the search criteria.
- **[setPhoto(communityId, userId, fileId, versionNumber)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setPhoto)**  
    Set an uploaded file as a user’s photo.
- **[setPhoto(communityId, userId, fileUpload)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setPhoto_2)**  
    Set a file that hasn’t been uploaded as the user’s photo.
- **[setPhotoWithAttributes(communityId, userId, photo)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setPhotoWithAttributes)**  
    Set and crop an uploaded file as a user’s photo.
- **[setPhotoWithAttributes(communityId, userId, photo, fileUpload)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_ChatterUsers_static_methods.htm#apex_ConnectAPI_ChatterUsers_setPhotoWithAttributes_2)**  
    Set and crop a file that hasn’t been uploaded as a user’s photo.

### deletePhoto(communityId, userId)

Delete a user’s photo.

#### API Version

28.0–34.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 35.0 and later, use [ConnectApi.UserProfiles.deletePhoto(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_UserProfiles_static_methods.htm#apex_ConnectAPI_UserProfiles_deletePhoto "Delete a user’s photo.")

#### Signature

public static Void deletePhoto(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

#### Return Value

Type: Void

### getGroups(communityId, userId)

Get the groups that a user is a member of.

#### API Version

28.0–44.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 45.0 and later, use [getUserGroups(communityId, userId)](#apex_ConnectAPI_ChatterUsers_getGroups_3 "Get a user’s groups.").

#### Available to Guest Users

32.0–44.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupPage getGroups(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

#### Return Value

Type: [ConnectApi.User​​GroupPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_page.htm "A paginated list of groups the context user is a member of.")

### getGroups(communityId, userId, pageParam, pageSize)

Get a page of groups that a user is a member of.

#### API Version

28.0–44.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 45.0 and later, use [getUserGroups(communityId, userId, pageParam, pageSize)](#apex_ConnectAPI_ChatterUsers_getGroups_4 "Get a page of a user’s groups.").

#### Available to Guest Users

32.0–44.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupPage getGroups(String communityId, String userId, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.User​​GroupPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_page.htm "A paginated list of groups the context user is a member of.")

### getPhoto(communityId, userId)

Get a user’s photo.

#### API Version

28.0–34.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 35.0 and later, use [ConnectApi.UserProfiles.getPhoto(communityId, userId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_UserProfiles_static_methods.htm#apex_ConnectAPI_UserProfiles_getPhoto "Get a user’s photo.").

#### Available to Guest Users

32.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.Photo getPhoto(String communityId, String userId)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

#### Return Value

Type: [ConnectApi.Photo](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_photo.htm "Profile photo.")

### searchUserGroups(communityId, userId, q)

Get the user’s groups that match the search criteria.

#### API Version

30.0–44.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 45.0 and later, use [searchUserGroupDetails(communityId, userId, q)](#apex_ConnectApi_ChatterUsers_searchUserGroups_3 "Get the user’s groups that match the search criteria.").

#### Available to Guest Users

32.0–44.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupPage searchUserGroups(String communityId, String userId, String q)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

#### Return Value

Type: [ConnectApi.User​​GroupPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_page.htm "A paginated list of groups the context user is a member of.")

### searchUserGroups(communityId, userId, q, pageParam, pageSize)

Get a page of a user’s groups that match the search criteria.

#### API Version

30.0–44.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 45.0 and later, use [searchUserGroupDetails(communityId, userId, q, pageParam, pageSize)](#apex_ConnectApi_ChatterUsers_searchUserGroups_4 "Get a page of a user’s groups that match the search criteria.").

#### Available to Guest Users

32.0–44.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.UserGroupPage searchUserGroups(String communityId, String userId, String q, Integer pageParam, Integer pageSize)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

q

Type: String

Required and can’t be null. Specifies the string to search. The search string must contain at least two characters, not including wildcards. See [Wildcards](https://developer.salesforce.com/docs/atlas.en-us.264.0.chatterapi.meta/chatterapi/intro_wildcards.htm).

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.User​​GroupPage](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_user_group_page.htm "A paginated list of groups the context user is a member of.")

### setPhoto(communityId, userId, fileId, versionNumber)

Set an uploaded file as a user’s photo.

#### API Version

28.0–34.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 35.0 and later, use [ConnectApi.UserProfiles.setPhoto(communityId, userId, fileId, versionNumber)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_UserProfiles_static_methods.htm#apex_ConnectAPI_UserProfiles_setPhoto "Set an uploaded file as a user’s photo.")

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.Photo setPhoto(String communityId, String userId, String fileId, Integer versionNumber)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

fileId

Type: String

ID of a file already uploaded. The file must be an image, and be smaller than 2 GB.

versionNumber

Type: Integer

Version number of the existing file. Specify either an existing version number, or null to get the latest version.

#### Return Value

Type: [ConnectApi.Photo](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_photo.htm "Profile photo.")

#### Usage

Photos are processed asynchronously and might not be visible right away.

### setPhoto(communityId, userId, fileUpload)

Set a file that hasn’t been uploaded as the user’s photo.

#### API Version

28.0–34.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 35.0 and later, use [ConnectApi.UserProfiles.setPhoto(communityId, userId, fileUpload)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_UserProfiles_static_methods.htm#apex_ConnectAPI_UserProfiles_setPhoto_2 "Set a file that hasn’t been uploaded as a user’s photo.")

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.Photo setPhoto(String communityId, String userId, ConnectApi.BinaryInput fileUpload)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

fileUpload

Type: [ConnectApi.Binary​​Input](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_binary.htm "Create a ConnectApi.BinaryInput object to attach files to feed items and comments, to add repository files, to create managed content, and to replace managed content variants.")

File to use as the photo. The content type must be usable as an image.

#### Return Value

Type: [ConnectApi.Photo](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_photo.htm "Profile photo.")

#### Usage

Photos are processed asynchronously and might not be visible right away.

### setPhotoWithAttributes(communityId, userId, photo)

Set and crop an uploaded file as a user’s photo.

#### API Version

29.0–34.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 35.0 and later, use [ConnectApi.UserProfiles.setPhotoWithAttributes(communityId, userId, photo)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_UserProfiles_static_methods.htm#apex_ConnectAPI_UserProfiles_setPhotoWithAttributes "Set and crop an uploaded file as a user’s photo.")

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.Photo setPhotoWithAttributes(String communityId, String userId, ConnectApi.PhotoInput photo)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

photo

Type: [ConnectApi.PhotoInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_PhotoInput.htm "Specify how to crop a photo that has already been uploaded.")

A ConnectApi.PhotoInput object specifying the file ID, version number, and cropping parameters.

#### Return Value

Type: [ConnectApi.Photo](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_photo.htm "Profile photo.")

#### Usage

Photos are processed asynchronously and might not be visible right away.

### setPhotoWithAttributes(communityId, userId, photo, fileUpload)

Set and crop a file that hasn’t been uploaded as a user’s photo.

#### API Version

29.0–34.0

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note_important.png)

#### Important

In version 35.0 and later, use [ConnectApi.UserProfiles.setPhotoWithAttributes(communityId, userId, photo, fileUpload)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_UserProfiles_static_methods.htm#apex_ConnectAPI_UserProfiles_setPhotoWithAttributes_2 "Set and crop a file that hasn’t been uploaded as a user’s photo.")

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.Photo setPhotoWithAttributes(String communityId, String userId, ConnectApi.PhotoInput photo, ConnectApi.BinaryInput fileUpload)

#### Parameters

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for the context user or the keyword me.

photo

Type: [ConnectApi.PhotoInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_PhotoInput.htm "Specify how to crop a photo that has already been uploaded.")

A ConnectApi.PhotoInput object specifying the cropping parameters.

fileUpload

Type: [ConnectApi.Binary​​Input](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_binary.htm "Create a ConnectApi.BinaryInput object to attach files to feed items and comments, to add repository files, to create managed content, and to replace managed content variants.")

File to use as the photo. The content type must be usable as an image.

#### Return Value

Type: [ConnectApi.Photo](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_photo.htm "Profile photo.")

#### Usage

Photos are processed asynchronously and might not be visible right away.