Unable to unregister plugin hook via plugin bootstrap

Elgg 3.3.15 version.

I wanted to unregister some menu from the topbar i.e. messages, using the plugin bootstrap approach. I can register my plugin hooks via the plugin bootstrap BUT cannot unregister some core/3rd-party plugin hooks. See a code snippet below:

use Elgg\DefaultPluginBootstrap;

class CustomBootstrap extends DefaultPluginBootstrap {

    public function init() {

        $hook = $this->elgg()->hooks;

        $hook->unregisterHandler('register', 'menu:topbar', 'messages_register_topbar');

    }   

    public function activate() {

    }   

}

I know I can unregister hooks in my_plugin/start.php by using elgg_unregister_plugin_hook_handler('register', 'menu:topbar', 'messages_register_topbar'). But I wanted to replace plugin/start.php with plugin/elgg-plugin.php and plugin/classes/PluginBootstrap.php.

Please advise why the above code snippet cannot unregister plugin hooks.

Thanks!

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking