Logged users only view/edit their own content

Hi everyone,
Plase can you help me please ?
I want to create a web platform with user roles. It works perfectly !

But I want logged users to only show/edit their owns contents in the panel.

Is it possible ? How to proceed please ?

Thanks a lot !

Check out Going beyond Kirby's permissions features | Kirby CMS

Thanks @texnixe, but it’s only for restricting access to specific user roles no ?

No, that’s why I pointed you to this method. It allows you to restrict access to individual users, provided a user is assigned to the page(s).

Hi,
Sorry for my misunderstanding… :frowning:
And thanks for this perfect trick !

So I made these changes and the “author” field now appears fine in my contents.

image image

But both authors John and San DOE can still view, access and edit all pages (but not the author owner)… :frowning:

Is there an other specifc variable to set in roles permissions ?

Thanks a lot for your help !

Which blueprint does this page use? And does your model use that same name?

Here is the bluprint’s “demande” that I use :

And the correspondig model :

So annoying… :sob:

Could you show what is in your model, please?

Sure, here is the /site/models/demande.php code :

<?php

use Kirby\Cms\Page;

class NotePage extends Page

{

  public function isReadable(): bool

  {

    if (($user = $this->author()->toUser()) && $user->is($this->kirby()->user()) ||

        $this->kirby()->user()->isAdmin()) {

      return true;

    }

    return false;

  }

}

Must be DemandePage extends Page

What a fool :confounded: !! Works perfectly :star_struck: :ok_hand: :+1: :pray: !!
Thanks a lot @pixelijn and @texnixe !!

I have made some changes to my file structure for a better role permissions folder/files edition

image

But since, panel don’t work. I have a “no blueprint exists” warning…

Any idea please ?

And here is my index.php

<?php

require __DIR__ . '/kirby/bootstrap.php';

$kirby = new Kirby();

$current_user = $kirby->user();

if ( $current_user && $current_user->role() == 'referent' ):

   $kirby = new Kirby([

      'roots' => [

         'blueprints' => __DIR__ . '/site/blueprintsreferent',

      ],

   ]);

elseif ( $current_user && $current_user->role() == 'admin' ):

   $kirby = new Kirby([

      'roots' => [

         'blueprints' => __DIR__ . '/site/blueprintsadmin',

      ],

   ]);

endif;

echo (new Kirby)->render();

Now your users blueprints won’t be found anymore. If you do it like this, you have to move all blueprints.

Sorry @texnixe, my kirby’s knowledge is not very advanced and neither is my English’s level…
You mean I have to put all my files in the blueprints folder without any other sub-folders ?

I restored my files folders tree like this and all works fine !

image

I will create another topic for permissions questions !

Now that we have dynamic blueprints and with the possibility to load blueprints by user, I think I would no longer use this hack with loading Kirby twice or even multiple times as in the example above.