This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

ivan_g
ivan_g

Hi guys, how can I hide the "Settings" menu from backend for a specific role?

I tried in the plugin.php, function boot, something like this:

            \Event::listen('backend.menu.extendItems', function($navigationManager) {
                 if ($iseditor) {
                   $navigationManager->removeMainMenuItem('October.System', 'system');
                 }
            });

and works fine, but to set the $iseditor I have to get the role of the logged user and this it's a pain right now... BackendAuth dosn't work (null), so, how can I do?

thanks!

daftspunky
daftspunky

The session is unavailable in service providers. Wrap it in this event to get access to the session:

App::before(function() { 
    // Place code in here
});
alezzzzz
alezzzzz

This might help others, you just need to get the user before:

$user = \BackendAuth::getUser();

this is what I did:

    \Event::listen('backend.menu.extendItems', function($navigationManager) {
        $user = \BackendAuth::getUser(); // get the logged in user
        if($user->hasAccess('acme.blog.*')):
               $navigationManager->removeMainMenuItem('October.System', 'system');
        endif;
    });

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.