You forgot to register the event 'register' => 'menu:title' in the elgg-plugin.php.
'events' => [
'register' => [
'menu:title' => [
'\MyPlugin\Profile\Menus\Title::register' => [],
],
],
],Now create a file \mod\my_plugin\classes\MyPlugin\Profile\Menus\Title.php with this code:
<?php
namespace MyPlugin\Profile\Menus;
class Title {
public static function register(\Elgg\Event $event) {
$user = $event->getEntityParam();
if (!$user instanceof \ElggUser || !$user->canEdit() || !elgg_in_context('profile')) {
return;
}
$return = $event->getValue();
$return[] = \ElggMenuItem::factory([
'name' => 'avatar:edit',
'icon' => 'image',
'text' => elgg_echo('avatar:edit'),
'href' => elgg_generate_entity_url($user, 'edit', 'avatar'),
'link_class' => ['elgg-button', 'elgg-button-action'],
]);
return $return;
}
}
Fantastic!
Thank you so much for the fast and easily understandable answer.
At least I had the folder path correct in the first try.
The idea for the menu was also the right one, but not fully correct.
And once again, I forgot to register the event in my plugin. That's a lesson you taught me before, but I forgot as I didn't do any updates on my Elgg since last Spring.
I applied the code already and it looks perfect now.
Once again, thank you very much for your help!
Can you use 'Developer tools' plugin to catch the error?
Switch on 'Enable error log' in the plugin's settings and reproduce your issue.
Now check out /admin/develop_tools/error_log
Because the log you provided doesn't clarify the details.
We'll have a look https://github.com/Elgg/Elgg/issues/14842
Will be fixed in the next Elgg release. https://github.com/Elgg/Elgg/pull/14849
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.