Restrict panel - now dropdown not working

I have set up a hook.
That works so far good. But when i try to click on the 3 point or try to adding a new post.
It shows “Dropdown is empty” - It’s cause im restricting the panel that user only can access there own post - and all other pages redirect to the site.yml

Bildschirmfoto 2022-10-10 um 19.45.16

I just tried it with /dropdowns/‘.$page->panel()->url(true).’?view=list&delete=true&sort=false’ but that does not work.

Maybe some has a hint for me? :slight_smile:

'hooks' => [
        'panel.route:before' => function($route, $path, $method) {
            $allowed = [];
            $user  = kirby()->user();
            if(!$user || !$path) return;
            $currentRole = $user->role()->name();
            if($currentRole == 'organizer') {
                $userPost = site()->find('company/products')->childrenAndDrafts()->filterBy('author', '- '.$user );
                
                foreach($userPost as $page) {

                    $allowed[] = [
                        'title' => $page->title()->value(),
                        'path'  => $page->panel()->url(true)
                    ];
                    
                    $allowed[] = [
                        'title' => $page->title()->value().'_dropdown',
                        // Just a test - not working
                        'path'  => '/dropdowns/'.$page->panel()->url(true).'?view=list&delete=true&sort=false'
                    ];
                };
              
                $allowed[] = [
                    'title' => 'Site',
                    'path'  => '/site'
                ];

                $allowed[] = [
                    'title' => 'Account',
                    'path'  => '/account'
                ];

                $allowed[] = [
                    'title' => 'Logout',
                    'path'  => '/logout'
                ];

                $allowedPaths = A::pluck($allowed, 'path');
                $currentPath  = '/'. $path;


                if(!in_array($currentPath, $allowedPaths)) {
                    Panel::go($allowedPaths[0]);
                }
        }
    }
    ]

Have you had a look at GitHub - sylvainjule/kirby-bouncer: Restrict access of a user role to a specific page (and its children) in the panel. which does something very similar than you want to do?

Yes there is where I copy the idea :slight_smile:
But i don’t check the whole code.
That could be a good hint → i will check it again complete :slight_smile:

That helps a lot . Just change a bit of the code

  if (Str::startsWith($path, "dialogs")
            || Str::startsWith($path, "dropdowns")
            || Str::startsWith($path, "search")) {
             return;
            }