How to show a popup when a Salesforce Experience/Community cloud Site user logs in for the first time?

How to show a popup when a Salesforce Experience/Community cloud Site user logs in for the first time?

In the following example, I have used a custom field on the Contact object to avoid showing the popup when the Experience/Community cloud Site user logs in for the first time.

1. Create a Custom Field in Contact object.

2.  Create the below Apex Class.

public with sharing class CommunityDetailsCheckController {  
    @AuraEnabled( cacheable = true )    
    public static String fetchContactInfo() {    
        User objUser = [ SELECT ContactId FROM User WHERE Id =: UserInfo.getUserId() ];  
        if ( string.isNotBlank( objUser.ContactId ) )  
            return objUser.contactId;    
            return null;  

3. Create the below Lightning Web Component.


    <template if:true = {objContact}>  
        <div class="demo-only" style="height: 640px;">  
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">  
                <div class="slds-modal__container">  
                    <header class="slds-modal__header">  
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModal}>  
                            <lightning-icon icon-name="utility:close" size="medium">  
                            <span class="slds-assistive-text">Close</span>  
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Please confirm your details</h2>  
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">                              
                            <lightning-record-edit-form record-id={objContact}    
                                <div class="slds-grid slds-wrap">    
                                    <div class="slds-col slds-size_1-of-2">                                
                                        <lightning-input-field field-name="FirstName">    
                                    <div class="slds-col slds-size_1-of-2">    
                                        <lightning-input-field field-name="LastName">    
                                    <div class="slds-col slds-size_1-of-2">                                
                                        <lightning-input-field field-name="Phone">    
                                    <div class="slds-col slds-size_1-of-2">    
                                        <lightning-input-field field-name="Email">    
                                    <div class="slds-col slds-size_1-of-2">    
                                        <lightning-input-field field-name="Confirm_Details__c">    
                                <lightning-button class="slds-m-top_small"    
                    <footer class="slds-modal__footer">  
                        <center><h1 style="color:green;">Please select Confirm Details 
check box to avoid seeing this pop up!!!</h1></center>  
            <div class="slds-backdrop slds-backdrop_open"></div>  
    <template if:true = {error}>    


import { LightningElement, track } from 'lwc';  
import fetchContactInfo from '@salesforce/apex/CommunityDetailsCheckController.fetchContactInfo';  
export default class CommunityDetailsCheck extends LightningElement {  
    @track error;   
    @track objContact;  
    connectedCallback() {    
        .then(result => {    
            this.objContact = result;    
        .catch(error => {    
            this.error = error;    
    handleSuccess( ) {    
        this.objContact = null;  
    closeModal() {  
        this.objContact = null;  


<?xml version="1.0" encoding="UTF-8"?>  
<LightningComponentBundle xmlns="">  

4. Create Audience in Community Cloud like below.

5. Add the Lightning Web Component to the Home page of the Community.

6. Make sure the visibility of the Lightning Web Component is set to that Audience.


Once the user select “Confirm Details” check box and clicks “Update”, the pop up won’t appear again for the user.

Leave a Reply