There's some strange behaviour in my application regarding the Ion Auth in_group function.
My authenticated user is part of group 2. When I execute the code $this->ion_auth->in_group(2)?'success':'fail'; the result is 'success' which is the expected result.
Passing an array like $this->ion_auth->in_group(2,4,5)?'success':'fail';, $this->ion_auth->in_group(array(2,4,5))?'success':'fail'; or $this->ion_auth->in_group($group_ids)?'success':'fail'; will always result in 'fail', which is not expected.
I can confirm that $group_ids is structured correctly:
Array
(
[0] => 2
[1] => 4
[2] => 5
)
As the Ion Auth documentation explains: TRUE if the user is in any of the given groups, FALSE otherwise. What might I be doing wrong?
Used Ion Auth version: 2.5.2
As a current work around (I don't want hardcoded groups), I'm using $this->ion_auth->in_group('order')?'success':'fail'; as my database is looking like this:
INSERT INTO user_groups(id, name, description, can_order)
VALUES(1,'admin','admin',0),
(2,'order','internal',1),(3,'controller','controller',0),
(4,'order','external 1',1),(5,'order','external 2',1)
Try using the latest Ion Auth code from the “2” branch in Github. There was a bug fix to the in group functionality a couple months ago, it might be related.