Article control via checkboxes in user-profiles

i’m trying to control articles over checkboxes in user-profiles but struggling to translate the checkbox array to a filter list in frontend.

at my user-blueprints theres a checkboxes field called “projekte” → projekt a, projekt b, projekt c

under a site called “kampagnen” are campaigns with the same checkboxes.

what i’m trying to archieve: if a user has “projekt a” and “projekt b” activted i its profile. he could see only campaigns with these checkboxes checked in frontend.

my idea is to user a filter in frontend:

filterBy('projekt', 'in', ['projekt a', 'projekt b'])

<?= $user->content()->projekt() ?>

returns-> ‘projekt a, projekt b’ instead of needed ‘projekt a’, ‘projekt b’.

is there anyone who could help?


No, you don’t want a string ‘projekt a’, ‘projekt b’, but an array ['projekt a', 'projekt b'].

You have to convert the field values into an array. This can be done with the split() field method.

filterBy('projekt', 'in', $user->project()->split(','))
1 Like

thank you @texnixe