【问题标题】:PHP CodeIgniter Ion Auth Creating a New GroupPHP CodeIgniter Ion Auth 创建一个新组
【发布时间】:2013-02-19 05:47:20
【问题描述】:

我正在建立一个网站,并且是 Codeigniter 和 Ion Auth 的新手。我的网站由三层用户组成:普通用户、版主和管理员。我了解 is_admin 和 is_logged in,但不知道如何为我的版主创建新组。

理想情况下,我想使用这样的东西来保护我的版主页面:

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');
}

如何为我的版主创建一个新用户组?这是我需要在我的数据库中做的事情吗?我在文档中看到了代码,但不确定在哪里/如何使用它。

【问题讨论】:

    标签: php codeigniter ion-auth codeigniter-helpers


    【解决方案1】:

    您可以手动将组添加到数据库的groups 表中-我想这对您来说最简单,因为您可能只需要执行一次-或者您可以使用库中内置的方法create_group()

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

    然后您将能够按照您的建议检查您的用户。

    【讨论】:

    • 感谢您的快速回复,但不幸的是我仍然不解!
    • 请告诉我什么需要澄清。您的问题是“如何为我的版主创建一个新的用户组?”什么不清楚?如何在groups 表中添加一行?如何使用建议的代码?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 2011-09-07
    • 1970-01-01
    • 2012-03-28
    • 2012-06-23
    • 2011-10-12
    相关资源
    最近更新 更多