Events can be used to extend the functionality of Social Poster.
beforeSavePost
event#Plugins can get notified before a post is saved. Event handlers can prevent the post from getting sent by setting $event->isValid
to false.
use craft\events\ModelEvent;
use verbb\socialposter\elements\Post;
use yii\base\Event;
Event::on(Post::class, Post::EVENT_BEFORE_SAVE, function(ModelEvent $event) {
$post = $event->sender;
$event->isValid = false;
});
afterSavePost
event#Plugins can get notified after a post has been saved
use craft\events\ModelEvent;
use verbb\socialposter\elements\Post;
use yii\base\Event;
Event::on(Post::class, Post::EVENT_AFTER_SAVE, function(ModelEvent $event) {
$post = $event->sender;
});
beforeSaveAccount
event#Plugins can get notified before an account is being saved.
use verbb\socialposter\events\AccountEvent;
use verbb\socialposter\services\Accounts;
use yii\base\Event;
Event::on(Accounts::class, Accounts::EVENT_BEFORE_SAVE_ACCOUNT, function(AccountEvent $event) {
// Do something
});
afterSaveAccount
event#Plugins can get notified after an account has been saved.
use verbb\socialposter\events\AccountEvent;
use verbb\socialposter\services\Accounts;
use yii\base\Event;
Event::on(Accounts::class, Accounts::EVENT_AFTER_SAVE_ACCOUNT, function(AccountEvent $event) {
// Do something
});
beforeDeleteAccount
event#Plugins can get notified before an account is deleted
use verbb\socialposter\events\AccountEvent;
use verbb\socialposter\services\Accounts;
use yii\base\Event;
Event::on(Accounts::class, Accounts::EVENT_BEFORE_DELETE_ACCOUNT, function(AccountEvent $event) {
// Do something
});
afterDeleteAccount
event#Plugins can get notified after an account has been deleted
use verbb\socialposter\events\AccountEvent;
use verbb\socialposter\services\Accounts;
use yii\base\Event;
Event::on(Accounts::class, Accounts::EVENT_AFTER_DELETE_ACCOUNT, function(AccountEvent $event) {
// Do something
});
beforeSaveToken
event#Plugins can get notified before a token is being saved.
use verbb\socialposter\events\TokenEvent;
use verbb\socialposter\services\Tokens;
use yii\base\Event;
Event::on(Tokens::class, Tokens::EVENT_BEFORE_SAVE_TOKEN, function(TokenEvent $event) {
// Do something
});
afterSaveToken
event#Plugins can get notified after a token has been saved.
use verbb\socialposter\events\TokenEvent;
use verbb\socialposter\services\Tokens;
use yii\base\Event;
Event::on(Tokens::class, Tokens::EVENT_AFTER_SAVE_TOKEN, function(TokenEvent $event) {
// Do something
});
beforeDeleteToken
event#Plugins can get notified before an token is deleted
use verbb\socialposter\events\TokenEvent;
use verbb\socialposter\services\Tokens;
use yii\base\Event;
Event::on(Tokens::class, Tokens::EVENT_BEFORE_DELETE_TOKEN, function(TokenEvent $event) {
// Do something
});
afterDeleteToken
event#Plugins can get notified after a token has been deleted
use verbb\socialposter\events\TokenEvent;
use verbb\socialposter\services\Tokens;
use yii\base\Event;
Event::on(Tokens::class, Tokens::EVENT_AFTER_DELETE_TOKEN, function(TokenEvent $event) {
// Do something
});
afterOauthCallback
event#use verbb\socialposter\controllers\AccountsController;
use verbb\socialposter\events\OauthTokenEvent;
use yii\base\Event;
Event::on(AccountsController::class, AccountsController::EVENT_AFTER_OAUTH_CALLBACK, function(OauthTokenEvent $event) {
// Do something
});