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.
You should override
'avatar/upload'action:Elgg docs.
Also, you can use 'action/validate' hook:
By the way, I don't recommend use
\Elggnamespace in your custom plugin. Use\MyPlugininstead