function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amit Kumar Singh 19Amit Kumar Singh 19 

Switch one community to another community based on single user login

We have multiple communities in our org.Say for example. c1,
User is trying to login via community "c1" portal and wants to navigate to "c2" community portal.
Is this possible to switch the community portal using single login?
global CommunitiesLoginController(){
        returnURL = ApexPages.currentPage().getParameters().get('returnURL');
        if(returnURL <> null){
            startURL = '/'+returnURL.substring((returnURL.lastIndexOf('/')+1));
        System.debug('RETURN URL>>>>>>>.'+returnURL);
    global PageReference login() {
        //Check Whether is already existing or Not
        if(returnURL <> null){
            PageReference authorized = Site.login(login_Username,login_Password,startURL);
            if(authorized <> null){
                List<User> userList = [Select Id,ContactId FROM User Where Username=:login_Username];
                System.debug('Result user>>>>>>.'+USERLIST.SIZE()+'Contact Id>>>>>>>'+userList[0].ContactId+'User Id>>>>>>'+userlist[0].id);
                if(userList.size() > 0){
                    List<Navigator_Contact__c> nc = [Select Account_Info__r.Order_Access__c FROM Navigator_Contact__c Where Parent_Contact__c=:UserList[0].ContactId];
                    sYSTEM.DEBUG('nAVIGATOR RESULT>>>>>'+nc);
                    if(nc.size() > 0){
                        if(nc[0].Account_Info__r.Order_Access__c == true){
                            system.debug('I am User but I have Order Navigator Access'+returnURL);
                            return authorized;
alvaro olivenciaalvaro olivencia
Did you find a solution to this ?