# Different custom panel CSS files for different user roles

**URL:** https://forum.getkirby.com/t/different-custom-panel-css-files-for-different-user-roles/14820
**Category:** Questions
**Tags:** v3
**Created:** [July 4, 2019, 11:28am UTC](https://forum.getkirby.com/t/different-custom-panel-css-files-for-different-user-roles/14820 "2019-07-04T11:28:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![joofu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joofu/32/7019_2.png) [@joofu](https://forum.getkirby.com/u/joofu)
#### Post date: [July 4, 2019, 11:28am UTC](https://forum.getkirby.com/t/different-custom-panel-css-files-for-different-user-roles/14820/1 "2019-07-04T11:28:19Z")

</div>

I would like to have different Custom Panel CSS files for different roles, e.g. to hide the Panel Search button at the top right (customers) or not (admin).

I tried two ‘solutions’, none of them were successful ☹  
Does anyone have another tip or are there errors in my attempts?  
Is it even possible to have different Panel CSS files?

Solution 1  
similar to the solution for role related blueprints I have set up the following plugin:

```auto
$user = $kirby->user();

if ($user && $user->role() == 'admin') {
    $dir = __DIR__. '/admin/';
} elseif ($user && $user->role() == 'editor') {
    $dir = __DIR__. '/editor/';
}

Kirby::plugin('jf/role-panelcss', [
    'panel' => [
    	'css' => $dir . 'css/custom-panel.css'
    ]

]);

```

The css files are located in the plugin-folder ‘/site/plugins/jf-role-panelcss/admin/css/custom-panel.css’ respectively ‘/site/plugins/jf-role-panelcss/editor/css/custom-panel.css’

Solution 2  
custom root setup  
index.php

```auto
require __DIR__. '/kirby/bootstrap.php';

$kirby = new Kirby();
$user = $kirby->user();

if ($user && $user->role() == 'admin') {
	$kirby = new Kirby([
		'roots' => [
			'assets' => __DIR__. '/site/assets/admin/'
		],
	]);

} elseif ($user && $user->role() == 'editor') {
	$kirby = new Kirby([
		'roots' => [
			'assets' => __DIR__. '/site/assets/editor/'
		],
	]);
}

echo $kirby->render();

```

config.php

```auto
return [

  'panel' => [
    'css' => kirby()->root('assets').'/css/custom-panel.css',
  ]

];

```

---

<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: [July 4, 2019, 11:44am UTC](https://forum.getkirby.com/t/different-custom-panel-css-files-for-different-user-roles/14820/2 "2019-07-04T11:44:15Z")

</div>

The second option won’t work because you can’t use `Kirby()` in the config.  
The first one won’t work because there is no such extension.

But you can use this approach and use different config roots based on user role instead: [https://getkirby.com/docs/reference/system/roots/config](https://getkirby.com/docs/reference/system/roots/config)

---

<div class="post-metadata">

### Author: ![joofu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joofu/32/7019_2.png) [@joofu](https://forum.getkirby.com/u/joofu)
#### Post date: [July 4, 2019, 1:36pm UTC](https://forum.getkirby.com/t/different-custom-panel-css-files-for-different-user-roles/14820/3 "2019-07-04T13:36:45Z")

</div>

@texnixe Thank you very much again! works great.

If someone needs this solution as well, please note that the role-specific config-root directories must obviously NOT be under site/config/, that didn’t work for me - I created a separate directory under /site.
