01-10-2019, 02:37 PM
Hello,
I am trying to build a dynamic NavBar depending on the permission level of the logged in user.
My first approach was something like:
But the problem is, that the list element doesn't even show up for the admin. When I echoed $permission it always showed "1" for all users I tried.
To me it looks like, that "$user->data()->permissions" outputs the permissions level of the user, that is necessary to access the current the page.
So when my page requires access level 1 and the admin has access levels 1 and 2, "$user->data()->permissions" outputs 1.
Does anyone know a solution or am I just on the wrong path?
PS: I started using UserSpice about a week ago and want to thank developers very much for this great tool!
I am trying to build a dynamic NavBar depending on the permission level of the logged in user.
My first approach was something like:
PHP Code:
$db = DB::getInstance();
$permission = $user->data()->permissions; //(Source: https://userspice.com/documentation-user-class/)
if ($permission == "2") { // "2" means admin
echo "<li><a href='overview.php'>Overview</a></li>";
}
But the problem is, that the list element doesn't even show up for the admin. When I echoed $permission it always showed "1" for all users I tried.
To me it looks like, that "$user->data()->permissions" outputs the permissions level of the user, that is necessary to access the current the page.
So when my page requires access level 1 and the admin has access levels 1 and 2, "$user->data()->permissions" outputs 1.
Does anyone know a solution or am I just on the wrong path?
PS: I started using UserSpice about a week ago and want to thank developers very much for this great tool!