Adding item in an Entity menu


I'm using Elgg 2.3.4 and working on adding a 'verify' menu item to an entity menu, blogs and comments to start, but eventually for any type of 'save' action.  I want this item to appear after the 'Like' (thumbs-up) icon. I took a look at the example at and understand what it's doing.  I've also been able to add a menu item to my topbar using: 

elgg_register_menu_item('topbar', array(

    'name' => 'tsnlogout',

    'href' => 'action/tsnlogout',

    'text' => 'Log Out',

    'parent_name' => 'account',

    'is_action' => true,

    'priority' => 1000, 'section' => 'alt',


My question is... can I use the 'elgg_register_menu_item' function to add my new 'verify' menu item to my blog and comment menus. If so, I'm stuck on how I can determine the name of the menu. Instead of 'topbar', what would my menu names be for 'blog' and 'comment'?


  • Out-of-box Elgg has some registered already menus, e.g with names 'topbar', 'site', 'page', owner_block' etc


    I've also been able to add a menu item to my topbar

    is right because 'topbar' menu.

    However, elgg has not menus with 'blog' or 'comment'.

    It could be 'entity' menu, or may be you meant 'owner_menu'?

    in this case you must use these names only in your hook.

    But you can create your own menu with custom name.

    In this case you can choose the custom menu's name and register your items there.

    Just learn docs.

    Tip: Use 'Elgg Developer' bundled plugin to inspect views, menus and more tools on your website.

  • Thanks RvR, 

    I understand how to add to the menu types like 'topbar', 'site', and 'page'.  I know that I need to add an item to an 'entity' menu... specifically the blog and comment entities.  It wasn't obvious to me how to do this from reading the docs.  So I assume I can do this in my start.php:

    elgg_register_plugin_hook_handler('register', 'menu:entity', 'my_entity_menu_handler');
    function my_entity_menu_handler($hook, $type, $items, $params) {
        $entity = $params['entity'];
        $handler = elgg_extract('handler', $params, false);
        if ($handler === 'blog') {
            // do something here to add a new menu item.
  • Almost...

    Instead of elgg_register_menu_item() use the ElggMenuItem class:

    $items[] = \ElggMenuItem::factory([
           'name' => 'register',
           'href' => elgg_get_registration_url(),
           'text' => elgg_echo('register'),
           'title' => elgg_echo('register'),
           'priority' => 200,
    At the end your function:
    return $items;
  • Ah.. ok.  Thank you.. that worked!