I wanted to listen to the onSetStatus event of the SetStatusElementAction and used the same code like in the EntryElementType class:

$setStatusAction = craft()->elements->getAction('SetStatus');
$setStatusAction->onSetStatus = function(Event $event) {

But it didn't work and I had to hack into the core making following code changes:

in the ElementsService class:

 * Fires an 'onSetStatus' event.
 * @param Event $event
 * @return null
public function onSetStatus(Event $event)
    $this->raiseEvent('onSetStatus', $event);

in the EntryElementType::getAvailableActions method where the onSetStatus is called:


This way I'm able to listen to the event in my plugin:

craft()->on('elements.setStatus', function() { ... });

The problem is that with the next update I have to do the code changes again. Is there a better way to listen to the event or is this worth a push request?

  • Craft 2.5.2750 seems to have introduced the elements.onPerformAction and elements.onBeforePerformAction events
    – oncode
    Commented Dec 23, 2015 at 14:15

1 Answer 1


As you've discovered, you should be using the more generic elements.onBeforePerformAction or elements.onPerformAction events. They get fired when any action takes place and you can check their action parameter to determine if it was a SetStatus action.

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.