$49

Ad Wizard

Documentation  •  Changelog

Documentation

Events

Craft 3 only

When saving a new (or existing) ad, there are two PHP events which will be triggered. Ads are elements, so they rely on the same element events as other Craft elements.

You can listen for these events by putting the following code in your custom module or plugin.

use doublesecretagency\adwizard\elements\Ad;
use craft\events\ModelEvent;
use yii\base\Event;

Event::on(
    Ad::class,
    Ad::EVENT_BEFORE_SAVE,
    function (ModelEvent $event) {
        // Do something before the ad is saved
    }
);
use doublesecretagency\adwizard\elements\Ad;
use craft\events\ModelEvent;
use yii\base\Event;

Event::on(
    Ad::class,
    Ad::EVENT_AFTER_SAVE,
    function (ModelEvent $event) {
        // Do something after the ad is saved
    }
);

For more information, consult the ModelEvent page of the Craft class reference documentation.