Remove CP Nav Items only for certain roles #4509
Answered
by
jasonvarga
ARCHES-Academy
asked this question in
Q&A
-
Is there a way to remove items from the CP Nav only if a user is a certain role? I've tried testing with an if (User::current()->hasRole('teacher')) {
Nav::extend(function ($nav) {
$nav->remove('Content');
});
} And I've also tried using the Nav::extend(function ($nav) {
$nav->remove('Content')->can('permission here');
}); Is there another way to do this, or is this simply impossible with the current version? |
Beta Was this translation helpful? Give feedback.
Answered by
jasonvarga
Oct 18, 2021
Replies: 1 comment 1 reply
-
Try putting the Nav::extend(function ($nav) {
if (User::current()->hasRole('teacher')) {
$nav->remove('Content');
}
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ARCHES-Academy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try putting the
hasRole
check inside theextend
.