Show info message in panel based on query if logged in user is contained in author field list

Hi,
I would like to show a message in the panel, in case the user has no rights to edit the page. Therefore, I want to check if the current logged in user is contained in my author field (multiple possible).

        query: >
          not page.author.toUser.id.find(kirby.user.id)

I’m struggling to find a working solution.

my article.yml
    fields:
      editPermissionInfo:
        type: info
        theme: warning
        label: ""
        text: |
          **Read only**
          You, logged in as »{{ kirby.user.username }}« ({{ kirby.user.role }}), do not have editing rights for this page.
        query: >
          not page.author.toUser.id.find(kirby.user.id)
[...]
  - width: 1/3
    sections:
      meta:
        type: fields
        fields:
          author:
            label: "Authors who can edit this article"
            type: users
            multiple: true
            translate: false

Thank You,
Christian

An info field doesn’t have a query option. If anything, you would probably want to show this field conditionally, but this type of more advanced when condition is possible via the the when property.

There used to be a plugin for Kirby 3 with more extensive options, but I guess you are on Kirby 4.

So maybe use PHP blueprints to show this field based on a condition: PHP-based blueprints | Kirby CMS

1 Like