I created customer portal with login enabled and assigned Customer Community Plus User to the portal with two users. I am able to login to the customer portal by using those two user's credentials.

Requirement : Now I have two users(Customer Community Plus Login User License) and I have two custom visualforce pages. I want to redirect to first visualforce page if the first user logged in and I want to redirect to second visualforce page if the second user logged in to the customer portal.

How to setup this retrictions for different users on visualforce page?

for example,

first person has access to --- first visualforce page 

second person has access to --- second visualforce page 

third person has access to --- all the visualforce pages

Thanks, Azar.

1 Answer 1


When you enable communities , some classes are by default created in your org. One of the class is "CommunitiesLandingController". You can use this class to perform redirection.

 * An apex page controller that takes the user to the right start page based on credentials or lack thereof
public with sharing class CommunitiesLandingController {

    // Code we will invoke on page load.
    public PageReference forwardToStartPage() {
        If(UserInfo.getUserName() == 'FirstuserName1'){
            PageReference pg = Page.FirstPage ; //your pagename1 here
            return pg;
        else if(UserInfo.getUserName() == 'SeconduserName1')}
            PageReference pg = Page.FirstPage ; //your pagename2 here
            return pg;
             return Network.communitiesLanding(); 

    public CommunitiesLandingController() {}

Check in the "forwardToStartPage()" method , the current user and redirect it to your desired page depending upon the condition, otherwise keep it default.

  • As I am new to customer portal usage, could you tell me how to check with current user. Which parameter I have to pass to check the user. Jan 25, 2016 at 9:44
  • I have updated my answer. you don't have to pass any parameters . It is available with the "UserInfo" class.
    – Nitin
    Jan 25, 2016 at 9:49
  • Ok thanks for your snippet. I'll check and come back Jan 25, 2016 at 9:49
  • I modified the controllerlandingpage class. Still when I log in it is redirecting to home.jsp page only Jan 25, 2016 at 10:02
  • you gave the username in the if the conditions right? Can you also put system.debug and check what is the "UserInfor.getUserName()" returning and is it matching with your username in the debug logs?
    – Nitin
    Jan 25, 2016 at 10:03

You must log in to answer this question.

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