title: How to set up user roles and permissions?
body: <p>I'm looking to add in some modifications to my application so that on my MY_Controller it checks to see if the user is allowed to access the current page or not. This is an example of one of my controllers. All of mine have a read, edit, create, delete functions. I just need to figure out how to globally set up permissions to allow or disallow a user from accessing it the function other than doing if statements on every function.</p>
  
  <pre><code>&lt;?php
  
  if (!defined('BASEPATH'))
      exit('No direct script access allowed');
  
  class Content_pages extends MY_Controller
  {  
      /**
       * Account::__construct()
       * 
       * Load the parent construct and any additional models, helper, libraries available. 
       * 
       * @return void
       */
      public function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;model('content_page_model', 'content_page');
      }
  
      /**
       * Content_pages::read()
       * 
       * @return
       */
      public function read()
      {     
          //vardump($this-&gt;user_data);
          // Checks to see if the user has a role id of four and if they do then it shows the admin dashboard and if not then shows the user dashboard.
          if ($this-&gt;user_data-&gt;access_level_id &gt;= 4)
          {
              // Retrieve all the users from the database that handle characters and assign it to the users variable.
              $content_pages = $this-&gt;content_page-&gt;get_all();
  
              // Place to dump the users array to verify it is the expected value.
              // vardump($users);
  
              // Checks to verify that there is data inside of the users array and that it is not empty.
              if (!empty($content_pages))
              {
                  $this-&gt;template-&gt;set('content_pages', $content_pages);
              }
  
              // Add the breadcrumbs to the view.
              $this-&gt;breadcrumb-&gt;add_crumb('&lt;li&gt;&lt;a href="' . base_url() . 'wrestling-manager/control-panel" class="glyphicons home"&gt;&lt;i&gt;&lt;/i&gt; Control Panel&lt;/a&gt;&lt;/li&gt;');
              $this-&gt;breadcrumb-&gt;add_crumb('&lt;li&gt;&lt;i&gt;&lt;/i&gt; Content Pages&lt;/li&gt;');
              $this-&gt;breadcrumb-&gt;change_link('&lt;li class="divider"&gt;&lt;/li&gt;');
  
              // Sets all the properites for the template view.
              $this-&gt;template
                  -&gt;set_theme('smashing')
                  -&gt;set_layout('control_panel_view')
                  -&gt;set_partial('header', 'partials/header')
                  -&gt;set_partial('sidebar','partials/sidebar')
                  -&gt;set_partial('footer', 'partials/footer')
                  -&gt;title('Content Pages')
                  -&gt;set('user_data', $this-&gt;user_data)
                  -&gt;build('content_pages_view');    
          }
          else
          {
              echo 'haha';
              //redirect('wrestling-manager/control-panel');
          }
      }
  
      /**
       * Content_pages::edit()
       * 
       * @return void
       */
      public function create()
      {
          echo 'testing for create function';
      }
  
      /**
       * Content_pages::edit()
       * 
       * @return void
       */
      public function edit($content_page_id)
      {
          vardump($content_page_id);
      }
  
      public function delete($content_page_id)
      {
          vardump($content_page_id);
      }
  
      /**
       * Content_pages::save()
       *  
       * @return
       */
      public function save()
      {
          echo 'testing for save function';
      }
  
      /**
       * Content_pages::update()
       * 
       * @return
       */
      public function update()
      {
          echo 'testing for update function';
      }
  }
  </code></pre>