Skip to content
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Solutions
    By Role
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    By Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    By Cloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    Partner Program
    Exclusive discounts, benefits and exposure to take your business to the next level
    Become a partner
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    Explore Features
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    Key Topics
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    Feature Packs
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    Featured Extension
    SocialBee
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • Extension
  • Pricing
  • Extensions
  • Help Center
  • More
    • Careers
    • Events
    • Plesk University
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Contact Us
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Contact Us
  • FREE TRIAL

Knowledge Base

Add Custom Events

 
extensions guideplesk features available for extensionssubscribe to plesk eventsaction logevents

Plesk SDK API allows you to add custom events, log them in the Action
Log, and assign event handlers via Plesk and the SDK API in extensions.

Custom events can be added by an ActionLog hook which extends the
pm_Hook_ActionLog
class and is located at hooks/ActionLog.php. The public method
getEvents()
should return the key value array. Where keys are unique (for this
extension), event ids and values are localized to the event title. To
avoid ids clashing, we add the ext_my-extension_ prefix to each event
id. To handle such an event via the SDK API, the id with the prefix
should be used. For example, your extension name is ‘my-extension’ and
the event id (in the hook) is ‘smth_created’. You need to catch the
action with the name ‘ext_my-extension_smth_created’ in the event
listener class.

A new class
pm_ActionLog
was added to provide the ability to fire events (method
pm_ActionLog::submit()).
It takes a number of arguments:

  • actionId (required) - an unique event id like it was specified in
    the hook.
  • objectId (optional) - a parameter to pass the object id for
    context (type: integer).
  • oldValue (optional) - a parameter for context to expose some
    changes.
  • newValue (optional) - a parameter for context to expose some
    changes.

Event handlers can also be added in Plesk (Tools & Settings =>
Event Manager).

These event handlers are stored in the extension’s settings
(pm_Settings)
in JSON format. The event handlers are removed automatically on
extension removal.

Examples

Add a custom event by hook

class Modules_MyExtension_ActionLog extends pm_Hook_ActionLog
{
    public function getEvents()
    {
        return [
            'smth_created' => 'Something created',
        ];
    }
}

Submit ActionLog event

/* Method in your controller */
public function addAction()
{
    $form = new AddSmthForm(['context' => [
        // pass some vars to context
    ]]);
    if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
        $status = 'success';
        $message = 'OK';
        try {
            $objectId = $form->processForm(); // Assume that form processing returns newly created object id
            // Submit action log event here
            pm_ActionLog::submit('smth_created', $objectId, 'old value', 'new value');
        } catch (pm_Exception $e) {
            $status = 'error';
            $message = $e->getMessage();
        }
        $this->_redirectWithStatus($status, $message, $this->getRedirectUrl());
    }
    $this->view->form = $form;
}

Handle an event via the SDK API

class Modules_MyExtension_EventListener implements EventListener
{
    public function handleEvent($objectType, $objectId, $action, $oldValue, $newValue)
    {
        if ($action == 'ext_myextension_smth_created') {
            pm_Log::info('Handle event: ext_myextension_smth_created');
            pm_Log::info('Object Id: ' . var_export($objectId, true));
            pm_Log::info('Old value: ' . var_export($oldValue, true));
            pm_Log::info('New value: ' . var_export($newValue, true));
        }
    }
}
return new Modules_MyExtension_EventListener();
Tweet
Share
Share
Email
0 Shares
Read the full article
Related Posts

Looking Back at APAC Partner Day 2022

Read More »

Workshops and Networking for Plesk Team at CodeFest 11

Read More »

CloudTalk 2021 – Join Plesk at the Virtual MatchMaking Summit

Read More »
Knowledge Base

Exercise 1. Tabs, Forms, Lists, Tools

Read More »

Extensions Reference

Read More »

Plesk Features Available for Extensions

Read More »

Available Licensing Models – Freemium Extensions

Read More »

Hosting Wiki

  • PhpMyAdmin
  • phpPgAdmin
  • PHP
  • Plesk

Industry
Partners

industry-partner_ALIBABA
industry-partner_GOOGLEPARTNER
industry-partner_MICROSOFT
industry-partner_REDHAT-r2
industry-partner_ALIBABA
industry-partner_AUTOMATTIC
industry-partner_AWS
industry-partner_DIGITALOCEAN
industry-partner_SCALEWAY
Follow us:
Facebook Twitter Linkedin Youtube Github

COMPANY

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY

Blog
Forums 
Plesk University

First defaul

Company

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE​

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS​

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY​

Blog
Forums
Plesk University

Follow us:
Facebook Twitter Linkedin Youtube Github

© 2025 WebPros International GmbH. All rights reserved. Plesk and the Plesk logo are trademarks of WebPros International GmbH.

Managed with love with Plesk WP Toolkit