Answers.Body: <p>In Craft there are several so called <a href="https://docs.craftcms.com/v2/templating/global-variables.html" rel="nofollow noreferrer">global variables</a> one of them is the <code>currentUser</code> thus you can check if someone is logged in with </p>
  
  <pre><code>{% if currentUser %} 
  
  {% else %} 
  
  {% endif %} 
  </code></pre>
  
  <p>You don't need to loop a user array </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-05T16:04:44.897Z
Answers.Text: aaah ok can I still target a certain user from the 'users group' with this {% if currentUser in craft.users.groups('nomads') %} As I am pulling some information so the form is already populated
Answers.UserDisplayName: Zack Reid
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-05T16:11:34.650Z
Answers.Text: Please read this https://craftcms.stackexchange.com/questions/1087/check-user-is-in-user-group-custom-user-permissions
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-05T15:27:29.893Z
Answers.LastActivityDate: 2018-05-05T15:27:29.893Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I have implemented an if/else statement and when I add the information to the 'else' part it outputs three duplicates of the same content.</p>
  
  <p>I am calling the if statement to check if the user is signed in here more andless.
  If they are they will get a booking form which shows up fine and only one of them.</p>
  
  <pre><code>{% for user in craft.users.groups('nomad') %}
  {% if user.isCurrent %}
  &lt;div class="wrapper"&gt;
  &lt;form method="post" action="" accept-charset="UTF-8"&gt;
      {{ getCsrfInput() }}
  
      {% for entry in craft.entries.section('studios').search(studio) %}
          &lt;input type="hidden" name="fields[studioEmail]" value="{{ entry.email 
      }}"&gt;
      {% endfor %}
      &lt;input type="hidden" name="action" 
      value="amForms/submissions/saveSubmission"&gt;
      &lt;input type="hidden" name="handle" value="bookingForm"&gt;
  
      {# Optional: Redirect URL. Will redirect to current page by default. #}
      &lt;input type="hidden" name="redirect" value="booking-form/thank-you"&gt;
  
      {{ craft.amForms.displayAntispam() }}
  
  
              &lt;div class="input__wrapper"&gt;
                  &lt;label for="fields-firstName" class="sr-only"&gt;First 
       Name&lt;/label&gt;
                  &lt;input type="text" id="fields-firstName" 
        name="fields[firstName]" autocomplete="off" placeholder="First Name" 
       value="{{ currentUser.firstName }}"&gt;
              &lt;/div&gt;
  
              &lt;div class="input__wrapper"&gt;
                  &lt;label for="fields-lastName" class="sr-only"&gt;Last Name&lt;/label&gt;
                  &lt;input type="text" id="fields-lastName" 
                 name="fields[lastName]" autocomplete="off" placeholder="Last 
                 Name" value="{{ currentUser.lastName }}"&gt;
              &lt;/div&gt;
  
              &lt;div class="input__wrapper"&gt;
                  &lt;label for="fields-mobileNumber" class="sr-only"&gt;Mobile Number&lt;/label&gt;
                  &lt;input type="text" id="fields-mobileNumber" name="fields[mobileNumber]" autocomplete="off" placeholder="Mobile Number" value="{{ currentUser.mobileNumber }}"&gt;
              &lt;/div&gt;
  
              &lt;div class="input__wrapper"&gt;
                  &lt;label for="fields-startDate" class="sr-only"&gt;Start 
                  Date&lt;/label&gt;
                  &lt;input type="text" id="fields-startDate" 
                  name="fields[startDate]" autocomplete="off" placeholder="start 
          Date"&gt;
              &lt;/div&gt;
  
              &lt;div class="input__wrapper"&gt;
                  &lt;label for="fields-endDate" class="sr-only"&gt;End Date&lt;/label&gt;
                  &lt;input type="text" id="fields-endDate" name="fields[endDate]" 
                  autocomplete="off" placeholder="End Date"&gt;
              &lt;/div&gt;
  
              &lt;div class="input__wrapper"&gt;
                  &lt;label for="fields-studio" class="sr-only"&gt;Studio&lt;/label&gt;
                  &lt;select name="fields[studio]" id="fields-studio"&gt;
                      {% for entry in craft.entries.section('studios').find() %}
                          &lt;option value="{{ entry.title }}"
  
                          {% if studio == entry.title %}
                                  selected="selected"
                          {% endif %}
  
  
                          &gt;{{ entry.title }}&lt;/option&gt;
                      {% endfor %}
                  &lt;/select&gt;
              &lt;/div&gt;
  
  
  
      &lt;input type="submit" value="Submit"&gt;
    &lt;/form&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>Then this is the else statement. I think I might need to add something to the     {% else %}. Though I don't see why it would be outputting three duplicates of the same content in the first place.</p>
  
  <pre><code>  {% else %}
    &lt;section class="form__wrapper"&gt;
    &lt;div class="content__form_wrapper sign-up_wrapper"&gt;
      &lt;h1&gt;Become a Digital Nomad and join the community&lt;/h1&gt;
      &lt;p&gt;You need to be a member to rent a desk, it will only take a moment of   
      your and you will be on your way.&lt;/p&gt;
  
      &lt;a href="{{ siteUrl }}users/sign-up" class=""&gt;Sign Up&lt;/a
  &lt;/div&gt;
  &lt;/section&gt;
  {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Thanks for the help :)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-05T12:11:35.963Z
Comments.Text: Maybe because there is a loop? It will output the content for each user in the group
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-05T14:38:02.263Z
Comments.Text: Yea it seems to be pulling in for each 'user', will try to fix it now.. Thanks for the help :)
Comments.UserDisplayName: Zack Reid
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-05T15:06:49.547Z
Comments.Text: Why do you even use this loop? It really makes no sense at all
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-05T15:21:07.143Z
Comments.Text: To be honest I didn't even know this was a loop :/..  I am just trying to display a form if the user is logged in. If they are not it won't show and sign up button will instead.. I thought an if/else statement would be the way todo this?
Comments.UserDisplayName: Zack Reid
Tags: <users><current-user>
Title: Else statement outputting three bits of content
ThreadText: # Else statement outputting three bits of content
  
  (Asked by: username_0 on 2018-05-05)
  
  I have implemented an if/else statement and when I add the information to the 'else' part it outputs three duplicates of the same content.
  
  I am calling the if statement to check if the user is signed in here more andless.
  If they are they will get a booking form which shows up fine and only one of them.
  
  ```
  {% for user in craft.users.groups('nomad') %}
  {% if user.isCurrent %}
  <div class="wrapper">
  <form method="post" action="" accept-charset="UTF-8">
      {{ getCsrfInput() }}
  
      {% for entry in craft.entries.section('studios').search(studio) %}
          <input type="hidden" name="fields[studioEmail]" value="{{ entry.email 
      }}">
      {% endfor %}
      <input type="hidden" name="action" 
      value="amForms/submissions/saveSubmission">
      <input type="hidden" name="handle" value="bookingForm">
  
      {# Optional: Redirect URL. Will redirect to current page by default. #}
      <input type="hidden" name="redirect" value="booking-form/thank-you">
  
      {{ craft.amForms.displayAntispam() }}
  
              <div class="input__wrapper">
                  <label for="fields-firstName" class="sr-only">First 
       Name</label>
                  <input type="text" id="fields-firstName" 
        name="fields[firstName]" autocomplete="off" placeholder="First Name" 
       value="{{ currentUser.firstName }}">
              </div>
  
              <div class="input__wrapper">
                  <label for="fields-lastName" class="sr-only">Last Name</label>
                  <input type="text" id="fields-lastName" 
                 name="fields[lastName]" autocomplete="off" placeholder="Last 
                 Name" value="{{ currentUser.lastName }}">
              </div>
  
              <div class="input__wrapper">
                  <label for="fields-mobileNumber" class="sr-only">Mobile Number</label>
                  <input type="text" id="fields-mobileNumber" name="fields[mobileNumber]" autocomplete="off" placeholder="Mobile Number" value="{{ currentUser.mobileNumber }}">
              </div>
  
              <div class="input__wrapper">
                  <label for="fields-startDate" class="sr-only">Start 
                  Date</label>
                  <input type="text" id="fields-startDate" 
                  name="fields[startDate]" autocomplete="off" placeholder="start 
          Date">
              </div>
  
              <div class="input__wrapper">
                  <label for="fields-endDate" class="sr-only">End Date</label>
                  <input type="text" id="fields-endDate" name="fields[endDate]" 
                  autocomplete="off" placeholder="End Date">
              </div>
  
              <div class="input__wrapper">
                  <label for="fields-studio" class="sr-only">Studio</label>
                  <select name="fields[studio]" id="fields-studio">
                      {% for entry in craft.entries.section('studios').find() %}
                          <option value="{{ entry.title }}"
  
                          {% if studio == entry.title %}
                                  selected="selected"
                          {% endif %}
  
                          >{{ entry.title }}</option>
                      {% endfor %}
                  </select>
              </div>
  
      <input type="submit" value="Submit">
    </form>
    </div>
  
  ```
  
  Then this is the else statement. I think I might need to add something to the {% else %}. Though I don't see why it would be outputting three duplicates of the same content in the first place.
  
  ```
    {% else %}
    <section class="form__wrapper">
    <div class="content__form_wrapper sign-up_wrapper">
      <h1>Become a Digital Nomad and join the community</h1>
      <p>You need to be a member to rent a desk, it will only take a moment of   
      your and you will be on your way.</p>
  
      <a href="{{ siteUrl }}users/sign-up" class="">Sign Up</a
  </div>
  </section>
  {% endif %}
  {% endfor %}
  
  ```
  
  Thanks for the help :)
  
  **Tags:** users, current-user
  
  > **Comments:**
  > **username_1**: Maybe because there is a loop? It will output the content for each user in the group  
  > **username_0**: Yea it seems to be pulling in for each 'user', will try to fix it now.. Thanks for the help :)  
  > **username_1**: Why do you even use this loop? It really makes no sense at all  
  > **username_0**: To be honest I didn't even know this was a loop :/..  I am just trying to display a form if the user is logged in. If they are not it won't show and sign up button will instead.. I thought an if/else statement would be the way todo this?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-05. Score: 1
  
  In Craft there are several so called [global variables](https://docs.craftcms.com/v2/templating/global-variables.html) one of them is the `currentUser` thus you can check if someone is logged in with
  
  ```
  {% if currentUser %} 
  
  {% else %} 
  
  {% endif %} 
  
  ```
  
  You don't need to loop a user array
  
  > **Comments:**
  > **username_0**: aaah ok can I still target a certain user from the 'users group' with this {% if currentUser in craft.users.groups('nomads') %} As I am pulling some information so the form is already populated  
  > **username_1**: Please read this https://craftcms.stackexchange.com/questions/1087/check-user-is-in-user-group-custom-user-permissions  
  
  ---
  
  