We have a community built using the Napili templates that contain a few custom made lightning components. The issue is all of the custom components display to guest community users. Depending on the data used in the component and the permissions attached to them, some of the components return empty values making it look like they don't work while others will function just fine. To add to the issue, the standard components either are hidden on the page or redirect to the login page depending on the page and component used, making the custom components behavior seem even more out of place.

I've looked at the options for access in aura:component but the only options appear to be 'public' and 'global', neither seeming to do what I want.

Instead of relying on the data to be the limiting factor for a components use to a guest community user, is there a way that I can just hide the entire component for this type of user?

2 Answers 2


You can use aura if to conditionally render elements for Guest User versus other profiles

 public class RichTextController {
   public static boolean isrendered(){
    boolean isrendered = true;
    if (UserInfo.getUserType() == 'Guest') {
        isrendered = false;
    return isrendered;

The lightning component code at the front end will look like below

<aura:component implements="forceCommunity:availableForAllPageTypes" controller="RichTextController">
    <aura:attribute name="rendered" type="boolean" default="true"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:renderIf isTrue="{!v.rendered}">


The Js controller

doInit : function(component, event, helper){
    var action = component.get('c.isrendered');

Another option would be to use Criteria Based Audiences which offers you the possibility of creating page variations depending on the current user profile. This is an OOTB functionality that the napili template offers for you to change what components or layout is displayed.

Since the Guest User licence cannot be selected from the profiles view when creating a page variation, set a Default view with "no profiles" and for the rest of the profiles, set a page variation with your custom components.

  • Does this allow the guest user to be specified as an audience? I am having trouble finding the guest profile in the list for an audience.
    – dsharrison
    May 30, 2017 at 1:57
  • 1
    Indeed, it is not under the options even when selecting the all profiles, in that case, you would need to default the view for what unauthenticated users see (default: guest user license) and when an authenticated user is on the community, set all their profiles to see the custom components.
    – glls
    May 30, 2017 at 2:26
  • This seems like a huge oversight from Salesforce, hopefully they will fix this.
    – dsharrison
    May 30, 2017 at 3:08
  • Indeed, but the process remains pretty straightforward. Just inverse the logic. ;)
    – glls
    May 30, 2017 at 3:09
  • Did you manage to make it work @dsharrison?
    – glls
    May 30, 2017 at 9:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .