Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have managed to create a custom context menu item in Umbraco 8 using a Component and a Composer.
The problem I have is that the new context menu item is available on every node (including Content and recycle bin) and for every user.
Is it possible to restrict it to specific users/groups and to only show for a specific tree level?
Hi Colin,
Yes, you can get the current users assigned permissions within your MenuRendering method
var permissions = sender.Services.UserService.GetPermissions(sender.Security.CurrentUser, nodeId);
you can then check these either against inbuild permission actions or your own custom ones (implement IAction to make custom ones) for example
if (permissions.Any(x => x.AssignedPermissions.Contains(ActionPublish.ActionLetter))) { /// user has publish permissions }
you can restrict by node based on the ID the recylce bin has a special ID.
so you can check if the node id passed matches that and ignore it.
if (nodeId.Equals(Constants.System.RecycleBinContentString)) { // in the bin }
see https://github.com/umbraco/Umbraco-CMS/tree/v8/contrib/src/Umbraco.Web/Actions for the inbuilt action classes
Thanks Kevin, that did the trick.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Adding custom context menu items to Umbraco 8
I have managed to create a custom context menu item in Umbraco 8 using a Component and a Composer.
The problem I have is that the new context menu item is available on every node (including Content and recycle bin) and for every user.
Is it possible to restrict it to specific users/groups and to only show for a specific tree level?
Hi Colin,
Yes, you can get the current users assigned permissions within your MenuRendering method
you can then check these either against inbuild permission actions or your own custom ones (implement IAction to make custom ones) for example
you can restrict by node based on the ID the recylce bin has a special ID.
so you can check if the node id passed matches that and ignore it.
see https://github.com/umbraco/Umbraco-CMS/tree/v8/contrib/src/Umbraco.Web/Actions for the inbuilt action classes
Thanks Kevin, that did the trick.
is working on a reply...