Tags

,

To check if the logged in user is a Guest user or not in the APEX code, we can make use of the method isGuestUser() in Auth.CommunitiesUtil class where Auth is the namespace that provides an interface and classes for single sign-on into Salesforce and session security management.

        if(Auth.CommunitiesUtil.isGuestUser())
        {
            <call method X>
        }
        else
        {
            <call method Y>
        }

Also, there is a method isInternalUser() which returns true if the logged in user is an employee or the Internal user.

Hope this post is helpful!!