I have a legacy v7 site for which we need to cancel any move operations for certain doctypes unless the user is in certain groups.
Using a ContentService.Moving event handler we can cancel the move easy enough however the event message does not bubble up the UI and the move action gets confirmed with a success message even though the node was not moved. Here is the event handler...
private void ContentServiceOnMoving(IContentService sender, MoveEventArgs<IContent> e)
{
var restrictedDoctypes = new[]
{
Blog.ModelTypeAlias,
NewsSection.ModelTypeAlias,
PressRelease.ModelTypeAlias
};
var doctypesBeingMoved = e.MoveInfoCollection.Select(d => d.Entity.ContentType.Alias);
if (!restrictedDoctypes.ContainsAny(doctypesBeingMoved) || !e.CanCancel) return;
e.CancelOperation(new EventMessage("Content Permissions", "You do not have permission to move this type of document", EventMessageType.Error));
}
I have also tried the following with no success:
e.Cancel = true;
e.Messages.Add(new EventMessage("Content Permissions", "You do not have permission to move this type of document", EventMessageType.Error));
Any ideas on how to force this message up to the UI?
EventMessage not shown when cancelling a move operation
I have a legacy v7 site for which we need to cancel any move operations for certain doctypes unless the user is in certain groups.
Using a
ContentService.Moving
event handler we can cancel the move easy enough however the event message does not bubble up the UI and the move action gets confirmed with a success message even though the node was not moved. Here is the event handler...I have also tried the following with no success:
Any ideas on how to force this message up to the UI?
Looks like it is a known bug and the pull request to fix it was never merged: https://github.com/umbraco/Umbraco-CMS/pull/3599
Unfortunately, this still seems broken in V10.4.0.
And also in V12.0.1. The same for copying...
Regards
Also broken for several of the member events as well.
is working on a reply...