Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 161 posts 322 karma points
    Mar 03, 2023 @ 14:52
    Tom
    0

    Event Handler for Recycle Bin's Delete...

    We are on Umbraco 10.4 and need to intercept the Recycle Bin's "Delete..."

    Does anyone know how to do this?

    Is there an Event Handler for this?

    Thanks

    Tom

  • Tom 161 posts 322 karma points
    Mar 03, 2023 @ 17:48
    Tom
    100

    This is the eventHandler that does the trick ContentDeletedNotification So for me in my C# .netCore6.0 project I added this line public void ConfigureServices(IServiceCollection services) {

                .AddNotificationHandler<ContentDeletedNotification, DeleteItemFromRecycleBin>()
    

    Then I created this class

    using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Notifications;

    namespace PWS.CMS { public class DeleteItemFromRecycleBin : INotificationHandler

        public DeleteItemFromRecycleBin(ILogger<DeleteItemFromRecycleBin> logger)
        {
            _logger = logger;
        }
        public void Handle(ContentDeletedNotification notification)
        {
            foreach (var recycleBinItem in notification.DeletedEntities)
            {
                _logger.LogInformation("{ContentName} was published", recycleBinItem.Name);
            }
        }
    }
    

    }

Please Sign in or register to post replies

Write your reply to:

Draft