I am working on Salesforce community. where I am getting one issue. Here is my issue.

I have configured 2 communities

  1. Lightning community
  2. Visualforce + tab community

I have one common visual force page for both community which contains one submit button. When user click on that submit button I have to redirect user to some page.

  • If Lightning community user click on that submit button I want to redirect to the lightning component.
  • If Visualforce + Tab community user click on that submit button I want to redirect to Apex page.

Note: I have common Apex controller to prepare URL for the submit button.

Issue: How I can identify user have clicked submit button from which community(Lightning community or Visuforce community)


First, I will recommend that you create a separate Lightning Aura Component so that you utilize that in case of Lighting Community and you don't have a dependency on the VF page.

If you cannot, then I would think you can utilize $User.UITheme here for the purpose (I haven't tried it myself). You can have this condition checked in your VF page to determine the Theme rendered for VF + Tabs (which will be Classic) vs. Lightning Community and utilize to render different command buttons serving different purpose.

Your submit button's implementation will then look like something as:

<apex:commandButton action="{!submitForClassic}" value="Submit" 
                    rendered="{!$User.UITheme == 'Theme3'}"/>

<apex:commandButton action="{!submitForLEX}" value="Submit" 
                    rendered="{!$User.UITheme == 'Theme4d'}"/>

This way only one of the buttons will be displayed on the VF page and that you can then handle the submit differently based on which one is clicked.

  • Thanx man..!!! it worked!!!!!!!!! – Chintal Somaiya Feb 21 '19 at 5:13

You can use Site.getName() to get the developer name of the Site you're currently in. See:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.