I've been trying to override the default user icon action.
my_plugin/classes/Elgg/MyHooksOverrides/EntityIconOverride.php :
<?php
namespace Elgg\MyHooksOverrides;
class EntityIconOverride {
public function __invoke(\Elgg\Hook $hook) {
return false;
}
}
my_plugin/elgg-plugin.php :
<?php
return [
'plugin' => [
'name' => 'My Plugin',
'activate_on_install' => true,
],
'view_extensions' => [],
'hooks' => [
'prepare' => [
'entity:avatar:prepare' => [
\Elgg\MyHooksOverrides\EntityIconOverride::class => [],
],
],
],
];
I've also tried this setup with `entity:icon:prepare` :
<?php
return [
'plugin' => [
'name' => 'My Plugin',
'activate_on_install' => true,
],
'view_extensions' => [],
'hooks' => [
'prepare' => [
'entity:avatar:prepare' => [
\Elgg\MyHooksOverrides\EntityIconOverride::class => [],
],
],
],
];
However, this is not having any effect. The hook should prevent the upload from proceeding, but the upload goes on successfully meaning that the plugin hook never gets called.
How can I make sure that my plugin hook gets called / OR, in other words, how can I override the default user icon upload action?
Thank you all in advance.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Jerome Bakker@jeabakker
Jerome Bakker - 1 like
- Revilo@Revilo
Revilo - 1 like
- Jerome Bakker@jeabakker
Jerome Bakker - 0 likes
You must log in to post replies.If you wish to fully take over the upload action, you can re-register the action in your plugin and also have the action file in your plugin.
Then on submit it'll go to your action file
http://learn.elgg.org/en/stable/guides/actions.html
I couldn't be more thankful for your reply Jerome Bakker. That was mighty helpful. I'll be using your suggestion.
I would, however, like to know why the hook wasn't being called, just in case I get to need to use hooks in the future. Hope you can help.
Your hook registration was wrong
I presume you wished to use this hook https://github.com/Elgg/Elgg/blob/94a075687edb5bdf71d7a28c016ca12856e4efa3/engine/classes/Elgg/EntityIconService.php#L214-L222
Which would be 'entity:avatar:prepare', 'user' not 'prepare' 'entity:avatar:prepare'