title: Change store view automatically for different customer groups in Magento 2
body: <p>I'm currently using Magento 2.3.2 and I would like to show certain customers a specific store view based on their customer group. (For example a customer in the "General" group would see the default store view, while a customer in the "Platinum" group would see the "Platinum" store view with a slightly different logo and design).</p>
  
  <p>Is there an extension out there that can do this? I can only find ones which restrict the products in the catalog?</p>
  
  <p><strong>Edit 20/02/2020 -</strong> </p>
  
  <p>Thanks to <a href="https://stackoverflow.com/users/9019169/invigorate-systems">Invigorate Systems</a> for the solution. I have now implemented the code as below in the app > code folders:</p>
  
  <blockquote>
    <p><strong>registration.php</strong> file inside <strong>GroupSite/SiteSwitch/</strong></p>
  </blockquote>
  
  <pre><code>&lt;?php
      \Magento\Framework\Component\ComponentRegistrar::register(
      \Magento\Framework\Component\ComponentRegistrar::MODULE,
      'GroupSite_SiteSwitch',
      __DIR__
      );
  </code></pre>
  
  <blockquote>
    <p><strong>module.xml</strong> file inside <strong>GroupSite/SiteSwitch/etc/</strong></p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"&gt;
              &lt;module name="GroupSite_SiteSwitch" setup_version="2.1.1"&gt;&lt;/module&gt;
  &lt;/config&gt;
  </code></pre>
  
  <blockquote>
    <p><strong>events.xml</strong> inside <strong>GroupSite/SiteSwitch/etc/frontend/</strong></p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"&gt;
      &lt;event name="layout_load_before"&gt;
          &lt;observer name="add_layout_handles" instance="GroupSite\SiteSwitch\Observer\AddHandles" /&gt;
      &lt;/event&gt;
  &lt;/config&gt;
  </code></pre>
  
  <blockquote>
    <p><strong>AddHandles.php</strong> file inside <strong>GroupSite/SiteSwitch/Observer</strong></p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  namespace GroupSite\SiteSwitch\Observer;
  
  use Magento\Framework\Event\Observer;
  use Magento\Framework\Event\ObserverInterface;
  use Magento\Customer\Model\Session as CustomerSession;
  
  class AddHandles implements ObserverInterface
  {
      protected $customerSession;
      protected $_storeManager;
      public function __construct(
          \Magento\Store\Model\StoreManagerInterface $storeManager,
          CustomerSession $customerSession
      ) {
          $this-&gt;customerSession = $customerSession;
          $this-&gt;_storeManager = $storeManager;
      }
  
      public function execute(\Magento\Framework\Event\Observer $observer)
      {
          $layout = $observer-&gt;getEvent()-&gt;getLayout();
           if ($this-&gt;customerSession-&gt;isLoggedIn()) 
               {
               $customerGroup = $this-&gt;customerSession-&gt;getCustomer()-&gt;getGroupId();
                  if($customerGroup === '5'){
                      $this-&gt;_storeManager-&gt;setCurrentStore('13'); //Set your desired store ID that you wish to set.
                  }
                  else{
                      $this-&gt;_storeManager-&gt;setCurrentStore('1');         
                  }
               }
      }
  }
  </code></pre>