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
GetRoles
#1
Hi guys, @mudmin made this function for me,

Code:
<?php getRoles(1);?>

<pre>
Code:
function getRoles($id, $opts = []){
  $db = DB::getInstance();
  $userQ = $db->query("SELECT * FROM user_permission_matches WHERE user_id = ?",array($id));
  $c = $userQ->count();

  if($c > 0){
    $results = $userQ->results();

  foreach ($results as $u){
    echoPerm($u->permission_id);
    $c = $c-1;
    if($c > 0){
      echo ", ";
    }
  }
}
}

function echoPerm($id){
  $db = DB::getInstance();
  $p = $db->query("SELECT * FROM permissions WHERE id = ?",array($id))->first();
  echo $p->name;
}
</pre>


it's about calling the role the user has on the site. For example, I am the administrator and the user and administrator come out under the photo. but if I enter as a user the same thing comes out, what it means is that that function calls all the permissions not precisely to the specific permission. There will be a way to call the right permit.

  Reply


Messages In This Thread
GetRoles - by shoropio - 02-06-2018, 12:45 AM
GetRoles - by mudmin - 02-06-2018, 12:49 AM
GetRoles - by shoropio - 02-06-2018, 12:52 AM
GetRoles - by mudmin - 02-06-2018, 12:57 AM
GetRoles - by mudmin - 02-06-2018, 12:57 AM
GetRoles - by shoropio - 02-06-2018, 01:23 AM
GetRoles - by shoropio - 02-06-2018, 01:35 AM
GetRoles - by shoropio - 02-06-2018, 02:20 AM
GetRoles - by mudmin - 02-06-2018, 02:34 AM
GetRoles - by shoropio - 02-06-2018, 03:09 AM
GetRoles - by mudmin - 02-06-2018, 03:47 AM
GetRoles - by shoropio - 02-06-2018, 01:39 PM
GetRoles - by mudmin - 02-06-2018, 01:42 PM
GetRoles - by shoropio - 02-06-2018, 02:41 PM
GetRoles - by shoropio - 02-06-2018, 02:42 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)