I want to list users that have created entries in a specific channel.
I tried it the Ben Parisak way, but that didn't work out.
here's the code that doesn't work (example 1):
{% set entryIds = craft.entries.section('agenda').datumBeginn('>= ' ~ todayMidnight).limit(null).ids() %}
{% set convivien = craft.users()
.group('convivien')
.status('active')
.cf_convivien_hide('not 1')
.relatedTo(entryIds)
.orderBy('firstName')
.all()
%}
If I had a user field within the agenda channel it would work. But I am trying to get the authors of those entries, and apparently they are not stored as a relation. Maybe this is intentional, maybe not.
Anyways: the workaround I found is really messy (example 2):
{% set entries = craft.entries.section('agenda').datumBeginn('>= ' ~ todayMidnight).limit(null).all() %}
{% set convivien = [] %}
{% for entry in entries %}
{% set author = entry.author %}
{% if author.groups[0].name == "Convivien" and not convivien|filter(item => item.id == author.id)|length %}{% set convivien = convivien|merge([{'name': author.name, 'id': author.id}]) %}{% endif %}
{% endfor %}
{% set convivien = convivien|sort %}
if code example 1 would work I could use the same code here:
<select name="convivien" id="veranstalter">
<option value="">{{ "Kanton wählen"|t }}</option>
{% for convivium in convivien %}
<option value="{{ convivium.id }}"{% if convivienParam == convivium.id %} selected="selected"{% endif %}>{{ convivium.name }}</option>
{% endfor %}
</select>
Does somebody know why example 1 is not working and how I could elegantly achieve this like I was Ben Parisak ;)