# User role only for the blog

**URL:** <https://forum.getkirby.com/t/user-role-only-for-the-blog/5966>\
**Category:** Questions\
**Tags:** v2\
**Created:** [December 5, 2016, 8:08pm UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966 "2016-12-05T20:08:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![guidoferreyra](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/guidoferreyra/32/12544_2.png) [@guidoferreyra](https://forum.getkirby.com/u/guidoferreyra)\
**Post date:** [December 5, 2016, 8:08pm UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/1 "2016-12-05T20:08:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 5, 2016, 8:29pm UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/2 "2016-12-05T20:29:31Z")

</div>

Something like this:

```auto
<?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:

- [https://getkirby.com/docs/cheatsheet#permissions](https://getkirby.com/docs/cheatsheet#permissions)
- [https://getkirby.com/docs/panel/permissions](https://getkirby.com/docs/panel/permissions)

---

<div class="post-metadata">

**Author:** ![guidoferreyra](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/guidoferreyra/32/12544_2.png) [@guidoferreyra](https://forum.getkirby.com/u/guidoferreyra)\
**Post date:** [December 6, 2016, 3:04am UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/3 "2016-12-06T03:04:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 6, 2016, 7:53am UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/4 "2016-12-06T07:53:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![guidoferreyra](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/guidoferreyra/32/12544_2.png) [@guidoferreyra](https://forum.getkirby.com/u/guidoferreyra)\
**Post date:** [December 8, 2016, 2:58pm UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/5 "2016-12-08T14:58:43Z")

</div>

It persist ☹

---

<div class="post-metadata">

**Author:** ![guidoferreyra](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/guidoferreyra/32/12544_2.png) [@guidoferreyra](https://forum.getkirby.com/u/guidoferreyra)\
**Post date:** [December 22, 2016, 2:49pm UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/6 "2016-12-22T14:49:48Z")

</div>

I couldn’t solve this. Any idea?

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [December 27, 2016, 8:21am UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/7 "2016-12-27T08:21:58Z")

</div>

try out this:

```auto
  // 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';
    }

  ]
];

```

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:53pm UTC](https://forum.getkirby.com/t/user-role-only-for-the-blog/5966/8 "2025-02-06T16:53:07Z")

</div>


