02-06-2018, 12:45 AM
Hi guys, @mudmin made this function for me,
<pre></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.
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;
}
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.