What is the correct way to add a new action to the current list of actions?

Is there a specific EE method to add a new action? Or is it just direct database manipulation(that is, add it via SQL)?


1 Answer 1


Usually it's done on the install method of your addon. Best practice is to take advantage of ActiveRecord and a db->insert:

$data = array(
    'class' => $this->class,
    'method' => $method

ee()->db->insert('actions', $data);

You don't need to specify an ACTion ID as this is auto incremented.

You can find a bit more information in the docs for Module Installation.

  • since v2.6 uses new super global: ee()->db->insert('actions', $data); Commented Jun 10, 2014 at 14:44
  • Could you submit your updated code as another answer for clarity?
    – Mutual
    Commented Jun 10, 2014 at 14:51
  • Whoops, thanks Peter, well spotted. :) Andrew, Peter has already outlined the updated way of using EE's super global method but I've updated my answer to reflect that.
    – Ian Young
    Commented Jun 10, 2014 at 19:11
  • Ah, I guess inserting the action to the database directly is the par of course. Commented Jun 11, 2014 at 3:28

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.