As here, I'm looking to set some variables for a module. Creating a DB table seems a bit overkill (or maybe it's really not). I've noticed that the Simple Commerce Module does two things: creates DB tables and adds to the config.php file. With the second method, it's using ee()->config->_update_config.

I cannot find any documentation on _update_config. It seems straight-forward enough, but I'm wondering if there's a reason I shouldn't use it.

In short, I'm looking to package a module for distribution, and I don't want to make it more complicated than it needs to be (e.g., I don't want to have to install an extension and a module). Is adding variable/settings to config.php a good idea?

2 Answers 2


I would store the settings in 'settings' column in 'exp_modules' table.

It does not exist in early versions of EE 2.x, so in your upd.my_module.php in function install() add


    // The settings column, Ellislab should have put this one in long ago.
    // No need for a seperate preferences table for each module.
    if ($this->EE->db->field_exists('settings', 'modules') == FALSE)
        $this->EE->dbforge->add_column('modules', array('settings' => array('type' => 'TEXT') ) );

and example save_settings() function can look like this

function save_settings()

    if (empty($_POST))


    $this->EE->db->where('module_name', 'My_module');
    $this->EE->db->update('modules', array('settings' => serialize($_POST)));


  • 1
    I’m a little late to this party, but this just recently came up on the EE Slack and I just want to make note that this is a really, really, really bad idea. Sorry. I know I’m coming in here and and raining on your parade. But you should never, ever, ever, ever, modify core tables. If EllisLab ever added a settings column themselves, the updater would throw a fatal error. Another add-on might get the same idea and try to do it. If you (add-on) did not create the table and don’t have sole control over it, you should not mess with the structure. Create your own table is the best bet.
    – TJ Draper
    Oct 13, 2016 at 18:19

You could try:

master config where you can set environment variables and custom global variables but this isnt done via control panel. In fact, quite the opposite happens. You set a variable in master config and it cant be changed in control panel. Handy when you have certain settings that need to be locked down.

stash and set user or site variables via an input form. Save variable and define an appropriate refresh period.

  • Neither option would work for me; as an example, I'm trying to save an Amazon Associate ID--that's not the kind of thing that changes nor do I want to constantly force the user to re-enter it. I suppose the easy way out is to tell people to add these variables directly to config.php, but why?
    – cherrypj
    Oct 14, 2013 at 19:19
  • Is that a unique value per member? If so ellislab.com/expressionengine/user-guide/cp/members/…
    – Lloyd Hill
    Oct 14, 2013 at 20:15
  • Or you can use this to edit/add config items. ellislab.com/expressionengine/user-guide/cp/admin/…
    – Lloyd Hill
    Oct 14, 2013 at 20:19
  • I'm trying to create a packaged module for distribution. I want the control panel access so people can add their own variables without having to deal with config.php. Let me clarify my question a bit.
    – cherrypj
    Oct 14, 2013 at 21:29
  • Sorry, i was responding to this comment... "I don't want to make it more complicated than it needs to be (e.g., I don't want to have to install an extension and a module)." I think you will need to make a mini module to do this.
    – Lloyd Hill
    Oct 14, 2013 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.