# Permission for only one specific page

**URL:** <https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 26, 2017, 2:05pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811 "2017-06-26T14:05:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mojo90](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mojo90/32/4040_2.png) [@Mojo90](https://forum.getkirby.com/u/Mojo90)\
**Post date:** [June 26, 2017, 2:05pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/1 "2017-06-26T14:05:24Z")

</div>

I have the requirement that there are some users which only have to go to one page in the panel and are allowed to upload images there.  
Out of the [Permissions-Site](https://getkirby.com/docs/panel/permissions) it does not work for me. I tried sth like this:

```auto
    <?php
    return [
      'name' => 'Fahrlehrer',
      'default' => false,
      'permissions' => [
        'panel.file.upload' => function() {
          return $this->target()->page()->template() === 'shop_fahrschueler';
        }
      ]
    ];
    ?>

```

---

<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:** [June 26, 2017, 2:22pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/2 "2017-06-26T14:22:59Z")

</div>

Try this:

```auto
<?php
   return [
     'name' => 'Fahrlehrer',
     'default' => false,
     'permissions' => [
       'panel.page.update' => false,
       'panel.page.read' => function() {
         return $this->target()->page()->template() === 'shop_fahrschueler';
       },
       'panel.file.upload' => function() {
         return $this->target()->page()->template() === 'shop_fahrschueler';
       }
     ]
   ];

```

---

<div class="post-metadata">

**Author:** ![Mojo90](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mojo90/32/4040_2.png) [@Mojo90](https://forum.getkirby.com/u/Mojo90)\
**Post date:** [June 26, 2017, 2:27pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/3 "2017-06-26T14:27:25Z")

</div>

Than it looks like this:

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/c/ce5f26c571efdb58da2a08a45c24062c88804d36.png)  
Could it be a problem that “shop\_fahrschueler” is a sub-page of “shop”?  
Here the corresponding blueprint of shop:

```
<?php if(!defined('KIRBY')) exit ?>

title: Shop
pages:
  template:
    - shop_category
    - shop_fahrschueler
```

---

<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:** [June 26, 2017, 2:33pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/4 "2017-06-26T14:33:56Z")

</div>

Yes, you then have to grant read access to the parent page as well.

---

<div class="post-metadata">

**Author:** ![Mojo90](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mojo90/32/4040_2.png) [@Mojo90](https://forum.getkirby.com/u/Mojo90)\
**Post date:** [June 26, 2017, 2:51pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/5 "2017-06-26T14:51:43Z")

</div>

Yes now it works with this:

```
<?php
return [
     'name' => 'Fahrlehrer',
     'default' => false,
     'permissions' => [
       'panel.page.update' => false,
       'panel.page.create' => false,
       'panel.page.delete' => false,
       'panel.page.url' => false,
       'panel.page.visibility' => false,
       'panel.page.read' => function() {
         $check = false;
         if($this->target()->page()->template() === 'shop'){
           $check = true;
         } else if($this->target()->page()->template() === 'shop_fahrschueler') {
           $check = true;
         }
         return $check;
       },
       'panel.file.update' => false,
       'panel.file.replace' => false,
       'panel.file.delete' => false,
       'panel.file.upload' => function() {
         return $this->target()->page()->template() === 'shop_fahrschueler';
       }
     ]
   ];
?>

```

But now I have one thing that is missing. Now the people can still change the template of a page. Is there an option here? Than I think the only thing what they could change is upload files to that specific page!

---

<div class="post-metadata">

**Author:** ![Mojo90](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mojo90/32/4040_2.png) [@Mojo90](https://forum.getkirby.com/u/Mojo90)\
**Post date:** [June 26, 2017, 2:57pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/6 "2017-06-26T14:57:38Z")

</div>

Managed it like so, think the most smartest way?

```
<?php
return [
     'name' => 'Fahrlehrer',
     'default' => false,
     'permissions' => [
       '*' => false,
       'panel.access' => true,
       'panel.widget.pages' => true,
       'panel.page.read' => function() {
         $check = false;
         if($this->target()->page()->template() === 'shop'){
           $check = true;
         } else if($this->target()->page()->template() === 'shop_fahrschueler') {
           $check = true;
         }
         return $check;
       },
       'panel.file.upload' => function() {
         return $this->target()->page()->template() === 'shop_fahrschueler';
       }
     ]
   ];
?>
```

---

<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:** [June 26, 2017, 2:58pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/7 "2017-06-26T14:58:01Z")

</div>

This can be shortened anyway and also prohibit changing of templates.

```auto
<?php
   return [
     'name' => 'Fahrlehrer',
     'default' => false,
     'permissions' => [
       'panel.page.*' => false,
       'panel.page.read' => function() {
         if($this->target()->page()->template() === 'shop' || $this->target()->page()->template() === 'shop_fahrschueler') return true;
       },
       'panel.file.upload' => function() {
         return $this->target()->page()->template() === 'blog';
       }
     ]
   ];

```

(Side note: don’t use a php closing tag in a php-only file)

---

<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, 5:35pm UTC](https://forum.getkirby.com/t/permission-for-only-one-specific-page/7811/8 "2025-02-06T17:35:31Z")

</div>


