3

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'
}) %}
  • Man, that's exactly what I would need too. Any progress on this? – outline4 Sep 04 '17 at 14:47
  • Any progress on this? I have the exact same problem to solve... – Joel Lachance Sep 06 '19 at 15:37
  • 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 – Bransin Dec 14 '20 at 16:52

1 Answers1

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

Bransin
  • 117
  • 7