October CMS resources and help articles

Simple and to the point. Optimized by the community.

Adding items to User Account Menu

2
by mjauvin, last modified on August 12th, 2019

If you want to add menu items under the User Account Menu, do the following:

\System\Classes\SettingsManager::instance()->registerCallback(function ($manager) {
    $manager->registerSettingItems('October.Backend', [
        'item1' => [
            'label'       => 'My Test Item',
            'url'         => Backend::url('<replace url here>'),
            'category'    => 'MyCategory',
            'context'     => 'mysettings',
        ],
        'item2' => [
            'label'       => 'My Test Item 2',
            'url'         => Backend::url('<replace url here>'),
            'category'    => 'MyCategory',
            'context'     => 'mysettings',
        ],
    ]);
});

Use removeSettingItem() method to remove items.

Discussion

3 comments

0
larryb
Post on September 18th, 2019 6:14 PM

Just wanted to throw this in that you can also remove these settings items:

\System\Classes\SettingsManager::instance()->registerCallback(function ($manager) {
    $manager->removeSettingItem('October.Backend', 'preferences');
});
0
azaharizaman
Post on October 23rd, 2019 7:22 PM

Where should we put this function into? Which file?

0
mjauvin
Post on October 27th, 2019 1:18 PM

You should add this code in any plugin register() or boot() method.

We use cookies to measure the performance of this website. Do you want to accept these cookies?