The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (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
Call the role
#1
Could you help me call the role? I do not know if I explain myself very well? there is a function to call the name, surname, income and more but I do not know if I can call example: admin and below the call the role. admin: admin, user: user, user: collaborator, etc.
  Reply
#2
There is no function, your best bet is to do the following:
http://pasted.co/d92c20c9

Replace ***USER ID HERE*** with $user->data()->id or the user ID you defined in whatever variable.

You will simply echo $userPerm and it will echo it.

NOTE: If the user has more than 1 perm, it will echo the lowest ID (e.g. user before admin). You might want to add a "importance" value in your permissions table and add an Order By to the query.

If you want to make that a function, you can put it in custom functions with a name and your DB:get instance and define the variable.
  Reply
#3
My friend you are a genius! and for users with two levels of permissions how do I apply a specific order?
  Reply
#4
I would add a column called "importance", this would be an integer column and you can set admin to 1, user to 2, whatever to 3, or however you want, and then add ORDER BY importance before the query turns into the array
  Reply
#5
Sorry...you call your order by BEFORE Limit
  Reply
#6
Many thanks @Brandin, It's a small step for a man, but a great leap for mankind.
  Reply
#7
If you want to display all permissions, we can help you with that too.
  Reply
#8
Yeah. I was just about to write a function for that when @Brandin beat me to it.
  Reply
#9
I also think it makes sense to just skip permission 1 (user) since everyone has it.
  Reply
#10
@karsen, @mudmin would you like to hear your thoughts?
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)