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
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
Call the role - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: Call the role (/showthread.php?tid=715)

Pages: 1 2


Call the role - shoropio - 09-03-2017

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.


Call the role - Brandin - 09-03-2017

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.


Call the role - shoropio - 09-03-2017

My friend you are a genius! and for users with two levels of permissions how do I apply a specific order?


Call the role - Brandin - 09-03-2017

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


Call the role - Brandin - 09-03-2017

Sorry...you call your order by BEFORE Limit


Call the role - shoropio - 09-03-2017

Many thanks @Brandin, It's a small step for a man, but a great leap for mankind.


Call the role - karsen - 09-03-2017

If you want to display all permissions, we can help you with that too.


Call the role - mudmin - 09-03-2017

Yeah. I was just about to write a function for that when @Brandin beat me to it.


Call the role - mudmin - 09-03-2017

I also think it makes sense to just skip permission 1 (user) since everyone has it.


Call the role - shoropio - 09-03-2017

@karsen, @mudmin would you like to hear your thoughts?