Welcome Guest, Not a member yet? Register   Sign In
access the array of roles
#1

I tried to access the array of roles from within my controller by using `$config['levels_and_roles']; but failed because the variable $config is not available. How to achieve that please ?
Reply
#2

Is it in application/config/???.php file?

You would need to load in config file in your controller somewhere, either in __construct method, autoload it site wide, or within specific URI method with $this->load->config('???.php')

You can access config options with $myConfigItems = $this->config->item('levels_and_roles');
Reply
#3

Example:

PHP Code:
./application/config/auth.php

/**
 * The array which holds your user groups and their ID.
 * If you have a database table for groups, these ID's must be the same as in the database.
 */
$config['auth_groups'] = array(
    
'admin'  => '1',
    
'editor' => '2',
    
'user'   => '100'
);


// to load the config.
$this->config->load('auth');

// to load the config item.
// where $group is group name.
$level $this->config['auth_groups'][$group]; 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB