Experience

A Brief Introduction to ExpressionEngine Actions

Published on 10th August, 2012

A couple of weeks ago, I announced that Testee 2.2 now lets you run your tests via an ACTion ID.

Whilst writing said announcement, I spent a few minutes scouring the ExpressionEngine documentation for a succinct ACTion ID overview that I could link to. I wasn’t expecting much, just an explanation of what an ACTion ID is and does, for the completely uninitiated.

The missing manual

The astute amongst you will have gathered that I found no such overview. There are a few developer-oriented mentions scattered about the place, but that’s about it.

This is a bit surprising, given that many (probably most) ExpressionEngine modules couldn’t function without the existence of ACTion IDs. If you’ve implemented a comments form, used the Simple Commerce module, or allowed a visitor to register as a Member, you’ve used ACTion IDs. They’re everywhere in EE.

Read on for my attempt to plug this hole in the ExpressionEngine documentation dam.

What it is

An ACTion ID is a number that appears in an ExpressionEngine URL as a query string parameter. It looks something like this:

http://example.com/index.php?ACT=123

Whenever ExpressionEngine encounters an ACTion URL, it attempts to run the code associated with the provided ACTion ID.

How it works

When an ACTion URL is loaded, ExpressionEngine looks in the exp_actions database table for an entry with the supplied ACTion ID. Each ACTion ID is associated with a class and method (i.e. the code to run).

Assuming the ACTion ID exists in the exp_actions table, ExpressionEngine automatically creates a new instance of the associated class, and calls the appropriate method.

What happens next is entirely up to the code being called. It could register a new Member, process a purchase, or drop all your database tables whilst emitting an evil cackle and twirling its moustache.

The latter scenario is why you should never install any software you dont trust; but Im sure anyone as whip-smart and fragrant as your good self already knew that.