Answers.Body: <p>You can just use:</p>
  
  <pre><code>{% for entry in craft.entries.section('downloads').relatedTo(currentUser) %}
      {{ entry.title }}
  {% endif %}
  </code></pre>
  
  <p>This is essentially returning an <code>ElementCriteriaModel</code> of reverse related entries sorted by entry date by default. You can also access the related entries through the field itself:</p>
  
  <pre><code>{% for entry in currentUser.selectDownloads %}
      {{ entry.title }}
  {% endif %}
  </code></pre>
  
  <p>This will loop through the related entries in the order they are sorted in the CP.</p>
  
  <p>But to answer your other questions. <code>sourceElement</code> and <code>targetElement</code> can be <code>elements</code> of any element type: entry, category, asset, user, globalSet, tag, etc are all elements. <code>sourceElement</code> simply refers to which is the source of the relationship; and <code>targetElement</code> is what it's related to. <code>field</code> further specifies that you only want to match a specific field rather than using any relationship defined in any field (if you have 2 or more <code>entries</code> fields defined in a channel that are used for different purposes for example).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-16T11:09:37.110Z
Answers.Text: My God. Craft is so wonderfully simple! I always look to far for an answer. Love it!
Answers.UserDisplayName: Tom De Smet
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-13T22:08:14.227Z
Answers.LastActivityDate: 2014-11-13T22:26:28.993Z
Answers.LastEditDate: 2014-11-13T22:26:28.993Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>The RelatedTo function keeps puzzeling me. I got it working with categories, but now I want to do something in reverse with users. But I don't fully understand the RelatedTo function.</p>
  
  <p>I have a channel called "downloads". I also have some users in the back-end. I have added a custom field to the user section called "selectDownloads". This field is a relatedEntry field where the admin can select entries from the downloads channel.
  Now I want to list all downloads in my template that the current logged in user may see (so the entries that were selected when creating the user).</p>
  
  <p>I read the docs multiple times allready and with some luck and trial and error I got it working on categories. But there I loop through all my products and relate them to a targetSource which is my category by a field that is part of my products channel.
  In this case however, I want to loop through all my downloads, related to a field that is part of my users section (instead of my downloads channel). So the relation is different.</p>
  
  <p>A more dummy proof explanation with some examples of the RelatedTo function would be welcome. I never know which elements I should address:</p>
  
  <pre><code> {% set ingredients = craft.entries.section('ingredients').relatedTo({
       sourceElement: cocktail,
       field: 'ingredients' }) %}
  </code></pre>
  
  <p><strong><code>sourceElement</code> or <code>targetElement</code>:</strong> </p>
  
  <p>Is this a section or field you have to give in?</p>
  
  <p><strong><code>field</code>:</strong></p>
  
  <p>Is that a field from the ingredients section or the cocktail section?</p>
  
Tags: <templating><relations><usermodel>
Title: RelatedTo with users
ThreadText: # RelatedTo with users
  
  (Asked by: username_0 on 2014-11-13)
  
  The RelatedTo function keeps puzzeling me. I got it working with categories, but now I want to do something in reverse with users. But I don't fully understand the RelatedTo function.
  
  I have a channel called "downloads". I also have some users in the back-end. I have added a custom field to the user section called "selectDownloads". This field is a relatedEntry field where the admin can select entries from the downloads channel.
  Now I want to list all downloads in my template that the current logged in user may see (so the entries that were selected when creating the user).
  
  I read the docs multiple times allready and with some luck and trial and error I got it working on categories. But there I loop through all my products and relate them to a targetSource which is my category by a field that is part of my products channel.
  In this case however, I want to loop through all my downloads, related to a field that is part of my users section (instead of my downloads channel). So the relation is different.
  
  A more dummy proof explanation with some examples of the RelatedTo function would be welcome. I never know which elements I should address:
  
  ```
   {% set ingredients = craft.entries.section('ingredients').relatedTo({
       sourceElement: cocktail,
       field: 'ingredients' }) %}
  
  ```
  
  **`sourceElement` or `targetElement`:**
  
  Is this a section or field you have to give in?
  
  **`field`:**
  
  Is that a field from the ingredients section or the cocktail section?
  
  **Tags:** templating, relations, usermodel
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-13. Score: 4 | Accepted answer
  
  You can just use:
  
  ```
  {% for entry in craft.entries.section('downloads').relatedTo(currentUser) %}
      {{ entry.title }}
  {% endif %}
  
  ```
  
  This is essentially returning an `ElementCriteriaModel` of reverse related entries sorted by entry date by default. You can also access the related entries through the field itself:
  
  ```
  {% for entry in currentUser.selectDownloads %}
      {{ entry.title }}
  {% endif %}
  
  ```
  
  This will loop through the related entries in the order they are sorted in the CP.
  
  But to answer your other questions. `sourceElement` and `targetElement` can be `elements` of any element type: entry, category, asset, user, globalSet, tag, etc are all elements. `sourceElement` simply refers to which is the source of the relationship; and `targetElement` is what it's related to. `field` further specifies that you only want to match a specific field rather than using any relationship defined in any field (if you have 2 or more `entries` fields defined in a channel that are used for different purposes for example).
  
  > **Comments:**
  > **username_0**: My God. Craft is so wonderfully simple! I always look to far for an answer. Love it!  
  
  ---
  
  