Welcome Guest, Not a member yet? Register   Sign In
ion_auth - view users of a certain group only
#1

[eluser]The Revel[/eluser]
I want to have a list that only lists admins but I cannot figure out where in the following code to limit it by group. In my old programming I always used access levels (number based) which allowed granting rights based on the number

i.e.

Code:
if ($access_lvl => 8)
{
//Do this
}

The access level was listed as a column in the user table. ion_auth uses Groups and these are stored in a different table. So getting a list of users on a certain access level (group) isn't as easy. The code I am looking to modify is the code in the Index in the original which I have now names as view_admins() and the listing of the users (all of them, despite group) is as follows:

Code:
//list the users
   $this->data['users'] = $this->ion_auth->users()->result();
   foreach ($this->data['users'] as $k => $user)
   {
    $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
   }

Now how do I pull a list of only a single group?
#2

[eluser]jellysandwich[/eluser]
It's built into the users() function.

Code:
public function users($groups = NULL)

If you look at the function, you'll see that $groups is supposed to be an int or array of ints.

Code:
//filter by group id(s) if passed
        if (isset($groups))
        {
         //build an array if only one group was passed
         if (is_numeric($groups))
         {
          $groups = Array($groups);
}




Theme © iAndrew 2016 - Forum software by © MyBB