0

I am building a website and am new to Codeigniter and Ion Auth. My website consists of three tiers of user: regular user, moderator and admin. I understand is_admin and is_logged in, but can't figure out how to create a new group for my moderators.

Ideally, I would like to use something like this to protect my moderator pages:

if (!$this->ion_auth->in_group('moderator'))
{
    //redirect them to the home page because they must be an administrator to view this
    redirect($this->config->item('base_url'), 'refresh');
}

How can I create a new group of user for my moderators? Is it something I need to do in my database? I've seen code in the documentation but am not sure where/how to use it.

Sparky
  • 98,165
  • 25
  • 199
  • 285
Gwenji
  • 117
  • 2
  • 11

1 Answers1

1

You can either manually add the group to the groups table of your db - I guess this is easiest for you as you probably only need to do it once - or you could use the method create_group() built into the library:

 $this->ion_auth->create_group('moderator', 'This is the moderators group');

Then you will be able to check your users as you suggest.

jtheman
  • 7,421
  • 3
  • 28
  • 39
  • Thank you for you quick response, but unfortunately I'm still puzzled! – Gwenji Mar 05 '13 at 08:04
  • Please tell me what need clarification. Your question is "How can I create a new group of user for my moderators?" What is unclear? How to add a row in your `groups` table? How to use the suggested code? – jtheman Mar 05 '13 at 10:17