Answers.Body: <p>For anyone that comes across this. Craft CMS has added this as a feature for next release.
  <a href="https://github.com/craftcms/cms/issues/7256#issuecomment-744644568" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/7256#issuecomment-744644568</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-14T19:41:03.630Z
Answers.LastActivityDate: 2020-12-14T19:41:03.630Z
Answers.UserDisplayName: Bransin
Body: <p>I have a channel section (<code>tickets</code>) where each entry has a <code>members</code> field. The <code>members</code> field can either be empty (making the entry 'public') or specific members can be added (making it 'private', to only the selected users).</p>
  
  <p>I want to get a list of all the entries within the section where the <code>members</code> field is <em>either</em> empty or the <code>currentMember</code> has been added to the list, e.g. a member should see both public entries <strong>and</strong> private entries they have been added to.</p>
  
  <p>I'm using the following to get all private entries for the currentMember, but I can't figure out how to make it include the public ones as well.</p>
  
  <pre><code>{% set tickets = craft.entries.section('tickets').relatedTo({
      targetElement: currentMember,
      field: 'members'
  }) %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T14:47:38.977Z
Comments.Text: Man, that's exactly what I would need too. Any progress on this?
Comments.UserDisplayName: outline4
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-09-06T15:37:59.763Z
Comments.Text: Any progress on this? I have the exact same problem to solve...
Comments.UserDisplayName: Joel Lachance
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-14T16:52:31.310Z
Comments.Text: I've submitted a bug report on this. This is something that should work out of the box in Craft without building two separate queries as others suggested. I would be shocked if they say it's not a bug and it's not possible. https://github.com/craftcms/cms/issues/7256
Comments.UserDisplayName: Bransin
Tags: <relations>
Title: Get entries where relation matches or is empty
ThreadText: # Get entries where relation matches or is empty
  
  (Asked by: username_0 on 2015-11-14)
  
  I have a channel section (`tickets`) where each entry has a `members` field. The `members` field can either be empty (making the entry 'public') or specific members can be added (making it 'private', to only the selected users).
  
  I want to get a list of all the entries within the section where the `members` field is *either* empty or the `currentMember` has been added to the list, e.g. a member should see both public entries **and** private entries they have been added to.
  
  I'm using the following to get all private entries for the currentMember, but I can't figure out how to make it include the public ones as well.
  
  ```
  {% set tickets = craft.entries.section('tickets').relatedTo({
      targetElement: currentMember,
      field: 'members'
  }) %}
  
  ```
  
  **Tags:** relations
  
  > **Comments:**
  > **username_1**: Man, that's exactly what I would need too. Any progress on this?  
  > **username_2**: Any progress on this? I have the exact same problem to solve...  
  > **username_3**: I've submitted a bug report on this. This is something that should work out of the box in Craft without building two separate queries as others suggested. I would be shocked if they say it's not a bug and it's not possible. https://github.com/craftcms/cms/issues/7256  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2020-12-14. Score: 1
  
  For anyone that comes across this. Craft CMS has added this as a feature for next release.
  <https://github.com/craftcms/cms/issues/7256#issuecomment-744644568>
  
  
  ---
  
  