CommunitiesUtil Class

Contains methods for getting information about an Experience Cloud user.

Namespace

Auth

Example

The following example directs a guest (unauthenticated) user to one page, and authenticated users of the Experience Cloud site’s parent organization to another page.
if (Auth.CommunitiesUtil.isGuestUser())
    // Redirect to the login page if user is an unauthenticated user
    return new PageReference(LOGIN_URL);       

if (Auth.CommunitiesUtil.isInternalUser())
    // Redirect to the home page if user is an internal user
    return new PageReference(HOME_URL);

CommunitiesUtil Methods

The following are methods for CommunitiesUtil. All methods are static.

getLogoutUrl()

Returns the page to display after the current Experience Cloud user logs out.

Signature

public static String getLogoutUrl()

Return Value

Type: String

getUserDisplayName()

Returns the current user’s Experience Cloud display name.

Signature

public static String getUserDisplayName()

Return Value

Type: String

isGuestUser()

Indicates whether the current user isn’t logged in to the Experience Cloud site. Redirect the user to log in, if necessary.

Signature

public static Boolean isGuestUser()

Return Value

Type: Boolean

isInternalUser()

Indicates whether the current user is logged in as a member of the parent Salesforce organization, such as an employee.

Signature

public static Boolean isInternalUser()

Return Value

Type: Boolean