CommunitiesUtil Class

Contains methods for getting information about a community user.

Namespace

Auth

Example

The following example directs a guest (unauthenticated) user to one page, and authenticated users of the community’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 community user logs out.
  • getUserDisplayName()
    Returns the current user’s community display name.
  • isGuestUser()
    Indicates whether the current user isn’t logged in to the community and may need to be redirected to log in, if required.
  • isInternalUser()
    Indicates whether the current user is logged in as a member of the parent Salesforce organization, such as an employee.

getLogoutUrl()

Returns the page to display after the current community user logs out.

Signature

public static String getLogoutUrl()

Return Value

Type: String

getUserDisplayName()

Returns the current user’s community display name.

Signature

public static String getUserDisplayName()

Return Value

Type: String

isGuestUser()

Indicates whether the current user isn’t logged in to the community and may need to be redirected to log in, if required.

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