Events#

Social Login provides a collection of events for extending its functionality. Modules and plugins can register event listeners, typically in their init() methods, to modify Social Login’s behavior.

User Events#

The beforeLogin event#

The event that is triggered before a user is logged in.

use verbb\sociallogin\events\UserEvent;
use verbb\sociallogin\services\Users;
use yii\base\Event;

Event::on(Users::class, Users::EVENT_BEFORE_LOGIN, function(UserEvent $event) {
    $user = $event->user;
    $userProfile = $event->userProfile;
    $provider = $event->provider;
    // ...
});

The afterLogin event#

The event that is triggered after a user is logged in.

use verbb\sociallogin\events\UserEvent;
use verbb\sociallogin\services\Users;
use yii\base\Event;

Event::on(Users::class, Users::EVENT_AFTER_LOGIN, function(UserEvent $event) {
    $user = $event->user;
    $userProfile = $event->userProfile;
    $provider = $event->provider;
    // ...
});

The beforeRegister event#

The event that is triggered before a user is registered.

use verbb\sociallogin\events\UserEvent;
use verbb\sociallogin\services\Users;
use yii\base\Event;

Event::on(Users::class, Users::EVENT_BEFORE_REGISTER, function(UserEvent $event) {
    $user = $event->user;
    $userProfile = $event->userProfile;
    $provider = $event->provider;
    // ...
});

The afterRegister event#

The event that is triggered after a user is registered.

use verbb\sociallogin\events\UserEvent;
use verbb\sociallogin\services\Users;
use yii\base\Event;

Event::on(Users::class, Users::EVENT_AFTER_REGISTER, function(UserEvent $event) {
    $user = $event->user;
    $userProfile = $event->userProfile;
    $provider = $event->provider;
    // ...
});

Connection Events#

The beforeSaveConnection event#

The event that is triggered before a connection is saved.

use verbb\sociallogin\events\ConnectionEvent;
use verbb\sociallogin\services\Connections;
use yii\base\Event;

Event::on(Connections::class, Connections::EVENT_BEFORE_SAVE_CONNECTION, function(ConnectionEvent $event) {
    $connection = $event->connection;
    $isNew = $event->isNew;
    // ...
});

The afterSaveConnection event#

The event that is triggered after a connection is saved.

use verbb\sociallogin\events\ConnectionEvent;
use verbb\sociallogin\services\Connections;
use yii\base\Event;

Event::on(Connections::class, Connections::EVENT_AFTER_SAVE_CONNECTION, function(ConnectionEvent $event) {
    $connection = $event->connection;
    $isNew = $event->isNew;
    // ...
});

The beforeDeleteConnection event#

The event that is triggered before a connection is deleted.

use verbb\sociallogin\events\ConnectionEvent;
use verbb\sociallogin\services\Connections;
use yii\base\Event;

Event::on(Connections::class, Connections::EVENT_BEFORE_DELETE_CONNECTION, function(ConnectionEvent $event) {
    $connection = $event->connection;
    // ...
});

The afterDeleteConnection event#

The event that is triggered after a connection is deleted.

use verbb\sociallogin\events\ConnectionEvent;
use verbb\sociallogin\services\Connections;
use yii\base\Event;

Event::on(Connections::class, Connections::EVENT_AFTER_DELETE_CONNECTION, function(ConnectionEvent $event) {
    $connection = $event->connection;
    // ...
});

Previous ← Custom Provider