View .md

UserEvent events

10 FeatherPanel plugin events on UserEvent (10 emitted by the core): the event names, the arguments each listener gets, where they fire and a PHP listener for each.

Last synced from FeatherPanel 15b94e9 on .

On this page

Part of the plugin events reference. Listeners get the payload values as positional arguments in the order shown, cannot cancel the action, and must catch their own exceptions.

Setup

Import UserEvent in your entry class and register listeners in processEvents():

<?php

namespace App\Addons\myplugin;

use App\App;
use App\Plugins\AppPlugin;
use App\Plugins\PluginEvents;
use App\Plugins\Events\Events\UserEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(UserEvent::onUserApiKeyCreated(), function ($userUuid, $apiClient): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:created ' . json_encode(['user_uuid' => $userUuid, 'api_client' => $apiClient]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

UserEvent::onUserApiKeyCreated()

Name: featherpanel:user:api_client:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: string user uuid, string api key id.

Same event name as UserApiClientEvent::onUserApiClientCreated(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
2api_client$apiClientstringfrom docblock
When it fires (1 site)
$event->on(UserEvent::onUserApiKeyCreated(), function ($userUuid, $apiClient): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:created ' . json_encode(['user_uuid' => $userUuid, 'api_client' => $apiClient]));
});

UserEvent::onUserApiKeyDeleted()

Name: featherpanel:user:api_client:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: string user uuid, string api key id.

Same event name as UserApiClientEvent::onUserApiClientDeleted(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
2api_client$apiClientstringfrom docblock
When it fires (1 site)
$event->on(UserEvent::onUserApiKeyDeleted(), function ($userUuid, $apiClient): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:deleted ' . json_encode(['user_uuid' => $userUuid, 'api_client' => $apiClient]));
});

UserEvent::onUserApiKeyUpdated()

Name: featherpanel:user:api_client:updatedemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: string user uuid, string api key id. (the emitter passes 3 values, see the table)

Same event name as UserApiClientEvent::onUserApiClientUpdated(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2api_client$apiClientnot declared
3updated_data$updatedDatanot at every sitenot declared
Arguments passedEmitted from
user_uuid, api_client, updated_data
ApiClientController::updateApiClient
user_uuid, api_client, action
ApiClientController::regenerateApiKeys
When it fires (2 sites)
$event->on(UserEvent::onUserApiKeyUpdated(), function ($userUuid, $apiClient, ...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:updated');
});

UserEvent::onUserCreated()

Name: featherpanel:user:createdemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: array user data, int user id, array created by. (the emitter passes 2 values, see the table)

#Payload keyListener parameterType
1user$usernot declared
2created_by$createdBynot at every sitenot declared
Arguments passedEmitted from
user, created_by
PterodactylImporterController::importUser
user, user_id, uuid, created_by
UsersController::create
When it fires (2 sites)
$event->on(UserEvent::onUserCreated(), function ($user, ...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:created');
});

UserEvent::onUserDeleted()

Name: featherpanel:user:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: array user data, array deleted by.

#Payload keyListener parameterType
1user$userarray
2deleted_by$deletedByarray|null
When it fires (1 site)
$event->on(UserEvent::onUserDeleted(), function ($user, $deletedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:deleted ' . json_encode(['user' => $user, 'deleted_by' => $deletedBy]));
});

UserEvent::onUserSshKeyCreated()

Name: featherpanel:user:ssh_key:createdemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: string user uuid, string ssh key id.

Same event name as UserSshKeyEvent::onUserSshKeyCreated(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1ssh_key$sshKeynot at every sitestringfrom docblock
2created_by$createdBynot at every sitestringfrom docblock
Arguments passedEmitted from
ssh_key, created_by
PterodactylImporterController::importSshKey
user_uuid, ssh_key
UserSshKeyController::createUserSshKey
When it fires (2 sites)
$event->on(UserEvent::onUserSshKeyCreated(), function (...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:ssh_key:created');
});

UserEvent::onUserSshKeyDeleted()

Name: featherpanel:user:ssh_key:deletedemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: string user uuid, string ssh key id.

Same event name as UserSshKeyEvent::onUserSshKeyDeleted(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
2ssh_key$sshKeystringfrom docblock
Arguments passedEmitted from
user_uuid, ssh_key
UserSshKeyController::deleteUserSshKey
user_uuid, ssh_key, action
UserSshKeyController::hardDeleteUserSshKey
When it fires (2 sites)
$event->on(UserEvent::onUserSshKeyDeleted(), function ($userUuid, $sshKey, ...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:ssh_key:deleted ' . json_encode(['user_uuid' => $userUuid, 'ssh_key' => $sshKey]));
});

UserEvent::onUserSshKeyUpdated()

Name: featherpanel:user:ssh_key:updatedemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: string user uuid, string ssh key id. (the emitter passes 3 values, see the table)

Same event name as UserSshKeyEvent::onUserSshKeyUpdated(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2ssh_key$sshKeynot declared
3updated_data$updatedDatanot at every sitenot declared
Arguments passedEmitted from
user_uuid, ssh_key, updated_data
UserSshKeyController::updateUserSshKey
user_uuid, ssh_key, action
UserSshKeyController::restoreUserSshKey
When it fires (2 sites)
$event->on(UserEvent::onUserSshKeyUpdated(), function ($userUuid, $sshKey, ...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:ssh_key:updated');
});

UserEvent::onUserUpdate()

Name: featherpanel:user:updateemitted at 1 siteCancel or modify: nodefinition

Docblock: string user uuid.

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
When it fires (1 site)
$event->on(UserEvent::onUserUpdate(), function ($userUuid): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:update ' . json_encode(['user_uuid' => $userUuid]));
});

UserEvent::onUserUpdated()

Name: featherpanel:user:updatedemitted at 4 sitesCancel or modify: nodefinition

Docblock: array user data, array updated data, array updated by.

#Payload keyListener parameterType
1user$userarrayfrom docblock
2updated_data$updatedDataarray
3updated_by$updatedByarrayfrom docblock
When it fires (4 sites)
$event->on(UserEvent::onUserUpdated(), function ($user, $updatedData, $updatedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:updated ' . json_encode(['user' => $user, 'updated_data' => $updatedData, 'updated_by' => $updatedBy]));
});