The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to: make permissions remove toolbar links
#1
In my toolbar I have a "Scripts" tab and an "Admin scripts" tab and I wanted to know how I can have the "Admin scripts" tab not show up if I'm logged in as a normal user.

Thanks
  Reply
#2
for logged in :


<pre>
Code:
$user->isLoggedIn()){
your content if logged in
}else{
your content not logged in
}
</pre>


also check if admin

Code:
if(checkMenu(2,$user->data()->id)) { your content }


  Reply
#3
Also, if you want to only allow more than one permission level to see something (or not see something), there's the hasPerm function

The venerable, old checkMenu function from the UserCake days was nice, but not really flexible as your number of permission levels grew. So, we have also added hasPerm. If you want something to show up (or not show up) or go through (or fail) based on a person’s permission level, you can now pass in an array.

Code:
if (hasPerm([2,103],$user->data()->id)){
Code:
//do something
Code:
}

You can pass in as many permission levels as you want into that [] array. Permission level ids can be found by going to the Admin dashboard and manage your permission levels. Click on one to get its id. Note that if you don’t make that first argument an array [] , it will throw an error, so use [] even if it is only for one permission level.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)