Retrieve the group id of user in Ion Auth - Codeigniter

WebNovice picture WebNovice · May 24, 2012 · Viewed 13.5k times · Source

I am using Ion Auth for my codeigniter application and all seems good except for one thing.

I need to display a list of users along with the groups they are in. How can I retrieve the group id of a particular user without making my own models and querying for it.

$this->ion_auth->user($id)->row(); does not retrieve the group id.

Answer

MY_Mark picture MY_Mark · May 24, 2012

Ion Auth has updated and removed the get_user function in the latest version. As a result of this, the below should return the current group id of the logged in user:

$this->ion_auth->get_users_groups()->row()->id

If you're wanting to get the group id of a particular user, you can pass the user id into the get_users_groups method.