Greetings to the Forum,I need to insert a menu item that I would like to make available to only one group of users. This entry does not belong to a classic table and therefore I cannot manage it from the userlevel table. Is it possible to manage and discriminate in any way the display of this item? Thanks
Put something like this in the Menu_Adding event:if ($item->Name == ‘mic_special_menu’)
return (UserLevelID() != 0);You’ll find the actual menu item name in ewmenu.php, and you use UserLevelID() or whatever logic seems reasonable to show/hide the menu item (the example will hide the menu item for members of “Default”).
Thanks, but … this is the error in my webpageNotice: Undefined variable: item in C:\Apache24\htdocs\odl_2020\ewshared12.php on line 928
Notice: Trying to get property of non-object in C:\Apache24\htdocs\odl_2020\ewshared12.php on line 928The name of my item is : TestThis is the string of my ewmenu.php after the compilation code :
$RootMenu->AddMenuItem(38, “mci_Test”, $Language->MenuPhrase(“38”, “MenuText”), “odladd.php”, -1, “”, IsLoggedIn(), FALSE, TRUE);This is my code on MenuItem_Adding
function MenuItem_Adding(&$Item) {
//var_dump($Item);
// Return FALSE if menu item not allowed
if ($item->Name == ‘mci_Test’)
return (UserLevelID() != 0);
}
$item is the object array passed to the menu_Adding event, so it looks like you forgot the $ sign somewhere
Ahhh … you used i but it should be I
I corrected the code as you suggested and now I don’t get an error anymore. The problem, however, is that all the menus disappeared and there is no longer the possibility of logging in …
Did you remove the “return TRUE;” at the end of the function? - it needs to be there to enable menu items by default.
Now i have this error :
Fatal error: Call to undefined function UserLevelID() in C:\Apache24\htdocs\odl_2020\ewshared12.php on line 929This is the code inside ewshared12.php at line 929 :
return (UserLevelID() != 0);This is the code of function
// MenuItem Adding event
function MenuItem_Adding(&$Item) {
//var_dump($Item);
// Return FALSE if menu item not allowed
if ($Item->Name == 'mci_Test')
return (UserLevelID() != 0);
return TRUE;
}
UserLevelID() is one of my custom functions - replace with CurrentUserLevel()
It’s perfect.
Thanks
Hey,currently I using HeroLib to track Cooldown on Items. Sadly sometimes if you press the Item to fast? There is no Cooldown on the Item shown internaly it has a Cooldown ofc.so it always return Cooldown = 0, while it still has Cooldown. is there any way to catch the Event:“Item is on Cooldown” and put it to variable 1 or 2?