Answers.Body: <p>I have found the solution to my problem.</p>
  
  <pre><code>{% if craft.app.request.isPreview %}
      THIS WILL BE SHOWN IN LIVE PREVIEW,
      even if Your domains are
      www.main-cp-domain.com
      www.second-domain.com
  {% else %}
     THIS WILL APPEAR TO ANYONE ON FRONTED
  {% endif %}
  </code></pre>
  
  <p>So it does what I need. However, I don't get why craft.app.request.isLivePreview and currentUser are not working in LivePreview, when editing entries for second-domain.com</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-26T10:40:12.857Z
Answers.LastActivityDate: 2019-09-26T10:40:12.857Z
Answers.UserDisplayName: klaxon
Body: <p>On multisite setup, I have problem to get LivePreview working (Craft 3.3.4). I have one domain live, other not, so it displays Maintenance Page. But I need the editors to edit the entries on that domain and check them in LivePreview.</p>
  
  <p>My templates begin like this:</p>
  
  <pre><code>{% if not currentUser %}
    {% include "_main/maintenance_page" %}
  {% else %}
    {% include "_main/general_page" %}
  {% endif %}
  </code></pre>
  
  <p>It should show the page when the user is logged in. But this doesn't work in LivePreview. Maintenance page is displayed in LP, what is not what I need to achieve.</p>
  
  <p>I have also tried</p>
  
  <pre><code>{% if craft.app.request.isLivePreview %}
  </code></pre>
  
  <p>but it returns FALSE for the inactive domain, when tested on LivePreview. So it is not working neither.</p>
  
  <p>Am I missing something? There is no guide in the Docs, afaik.</p>
  
  <p>Thanks</p>
  
Tags: <craft3><multi-site><live-preview>
Title: On multisite setup, currentUser not true in LivePreview
ThreadText: # On multisite setup, currentUser not true in LivePreview
  
  (Asked by: username_0 on 2019-09-24)
  
  On multisite setup, I have problem to get LivePreview working (Craft 3.3.4). I have one domain live, other not, so it displays Maintenance Page. But I need the editors to edit the entries on that domain and check them in LivePreview.
  
  My templates begin like this:
  
  ```
  {% if not currentUser %}
    {% include "_main/maintenance_page" %}
  {% else %}
    {% include "_main/general_page" %}
  {% endif %}
  
  ```
  
  It should show the page when the user is logged in. But this doesn't work in LivePreview. Maintenance page is displayed in LP, what is not what I need to achieve.
  
  I have also tried
  
  ```
  {% if craft.app.request.isLivePreview %}
  
  ```
  
  but it returns FALSE for the inactive domain, when tested on LivePreview. So it is not working neither.
  
  Am I missing something? There is no guide in the Docs, afaik.
  
  Thanks
  
  **Tags:** craft3, multi-site, live-preview
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-09-26. Score: 1
  
  I have found the solution to my problem.
  
  ```
  {% if craft.app.request.isPreview %}
      THIS WILL BE SHOWN IN LIVE PREVIEW,
      even if Your domains are
      www.main-cp-domain.com
      www.second-domain.com
  {% else %}
     THIS WILL APPEAR TO ANYONE ON FRONTED
  {% endif %}
  
  ```
  
  So it does what I need. However, I don't get why craft.app.request.isLivePreview and currentUser are not working in LivePreview, when editing entries for second-domain.com
  
  
  ---
  
  