Cockpit - Different view rights on same collection?


#1

Hi guys,

for a customer of me, I need a way to have a blog and event collection where different users can create, edit and delete the collections. The struggle I have is the following:

  • How can I only show them the collections posts with them as author.

The only workaround I found was creating for every user a different blog and event collection, and create a different user group per user. This will use a lot of time and a little bit of “hacking”, anyone has a solution?


#2

Hey @joeyjreij, think you can implement a event of type collections.find.before.{$name} and provide the filtering there, e.g.:

$app->on('collections.find.before.posts', function ($name, &$options) use ($app) {
  $user = $app->module('cockpit')->getUser();
  $options['filter']['_by'] = $user['_id'];
});