User role only for the blog

Hi I searched the forum and because user permission is something new I didn’t found any clue on how to set up an user role that can only edit the blog.
Anyone can help me with this?

Thanks in advance.

Something like this:

<?php

// site/roles/editor.php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'                 => true,
    'panel.site.update' => false,
    'panel.user.*'      => false,
    'panel.page.*'      => false,
    'panel.page.read'   => true,
    'panel.page.update' => function() {
      return $this->target()->page()->template() === 'article';
    },
    'panel.page.delete' => function() {
      return $this->target()->page()->intendedTemplate() === 'article';
    },
    'panel.page.create' => function() {
      return $this->target()->page()->template() === 'blog';
    }


  ]
];

You can find all about permission in the docs:

Thanks!
I think there is a little bug when this user role modifies the article page it gets the message “You are not allowed to do this” but actually the changes are saved. So I think the red message is wrong should be the green one

Thanks again.

Ok, thanks for letting me know, I’ll look into this.

Edit: At first try, I also got this error message, but after I reloaded, it disappeared. Could you try if it persists when you log out and in again?

It persist :frowning2:

I couldn’t solve this. Any idea?

try out this:

  // site/roles/editor.php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'                 => true,
    'panel.site.update' => false,
    'panel.user.*'      => false,
    'panel.page.update' => true,
    'panel.page.delete' => true,
    'panel.page.create' => true,
  
    'panel.page.read' => function() {
      return 
      $this->target()->page()->template() === 'article'||
      $this->target()->page()->template() === 'blog';
    }


  ]
];