User permissions for specific fields

Hello,

is there a way in the panel to display individual input fields only for a certain user group?

Like in this example. The user-x is only allowed to edit the content text.

ADMIN

** Title **
** Content **
** Author **

USER-X

** Content **

Thanks!

As far as I know, you can’t hide individual fields from the panel for individual users, but you can prevent updates on a per field basis as shown in the docs: https://getkirby.com/docs/cheatsheet/permissions/panel-page-update

Edit: no, this won’t work! A page can only be updated as a whole, it is not possible to exclude individual fields.

Your best bet is a custom Panel field that is disabled for certain user roles.

Thank you. I think this should work for me

How set it to disabled?

I return a empty field in the input method if the roles does not fit like:

	public function input() {

	    if( $user = site()->user() and $user->hasRole('editor') or $user->hasRole('admin') ) {
         ......
	} else {
		return '';
		}
	}

Works but i get a empty wrapper for the hidden field then… so there are nasty whitespaces below panel fields.

<div class="field field-grid-item field-name-auditdiff">
  <div class="field-content"></div>
</div>

Any idea how i can get rid of this?

Svnt

Don’t display the element either, if wrong user.

How can i do this on a panel field?

The base field comes with an element method, so you would override that like you override the input method.

1 Like