Dalibor
Dalibor

Reputation: 1572

Umbraco - when editor create content send email notification to admin

Is it possible? I am an admin. I want to be notified by email when editor (or writer or whom ever with the access) creates some content (e.g. enters some News in News document type). And how? I use Umbraco 7.5

Upvotes: 1

Views: 496

Answers (2)

Nurhak Kaya
Nurhak Kaya

Reputation: 1781

You can either write your own custom code by creating some event handlers, which is what @wingyip has recommended, or you can use built-in Umbraco notification functionality.

For the second built-in option, please see all the steps here on this post.

Upvotes: 0

wingyip
wingyip

Reputation: 3536

You need to code into Umbraco ContentService events.

The following should get you started. It will be triggered whenever an item is published.

Be careful what you wish for though. You may get a barrage of useless emails if somebody publishes a parent node along with all of its child nodes.

There are other events that you can hook into so please refer to documentation at https://our.umbraco.com/Documentation/Reference/Events/ContentService-Events-v7.

using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;

namespace My.Namespace
{
    public class MyEventHandler : ApplicationEventHandler
    {

        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentService.Published += ContentServicePublished;
        }

        private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
        {
            foreach (var node in args.PublishedEntities)
            {
                 // Your code to send email here
            }
        }
    }
}

Upvotes: 2

Related Questions