I'm rather new at CodeIgniter and especially Ion Auth. I'm building a website which will have three tiers of user: User, Moderator and Admin. My aim is to use this code snippet:
if (!$this->ion_auth->in_group('moderator'))
{
//redirect them to the because they must be a moderator
redirect($this->config->item('base_url'), 'refresh');
}
to check if user is an administrator before granting access.
I have already edited my 'groups' table as follows:
(ID, name, description) 1 admin Administrator, 2 members General User, 3 moderator Moderators
I have also updated one user in my 'user_groups' table to have 'group_id' of '3'.
However, when I test my code, it will always allow my admin to see the page (which is fine) but it will redirect my moderator.
I haven't changed anything in my ion_auth library file, or any models, but I did manually create and insert into all my tables as MySql didn't like it being loaded.
EDIT: I think it may be connected to my Databases, as I've tried to promote a user to an admin by changing their 'group_id' in the 'users_group' table and my website won't recognize them as an admin. However, I am not receiving any errors, but my code is just not recognizing anyone but the admin.
Thank you in advance for any help you can give - I'm pulling my hair out!!!