We have moved!

You are currently looking at documentation for Umbraco 8 and older versions.
Go to docs.umbraco.com/umbraco-cms/reference/notifications/memberservice-notifications for documentation for Umbraco 9 and newer versions.

    MemberService Events

    The MemberService implements IMemberService and provides access to operations involving IMember.

    Are you using Umbraco 9?

    Note that in Umbraco 9, MemberService Events have been renamed to MemberService Notifications.

    Find more information about notifications in Umbraco 9 in the Notifications section.

    Usage

    Example usage of the MemberService events:

    using System;
    using Umbraco.Core;
    using Umbraco.Core.Composing;
    using Umbraco.Core.Services.Implement;
    using Umbraco.Core.Events;
    using Umbraco.Core.Models;
    using Umbraco.Core.Services;
    
    namespace Umbraco8.Components
    {
        [RuntimeLevel(MinLevel = RuntimeLevel.Run)]
        public class SubscribeToSavedEventComposer : ComponentComposer<SubscribeToSavedEventComponent>
        { }
        
        public class SubscribeToSavedEventComponent : IComponent
        {
            private readonly ILogger _logger;
    
            public SubscribeToSavedEventComponent(ILogger logger)
            {
                this._logger = logger;
            }
           
            public void Initialize()
            {
                //specify my event handler
                MemberService.Saved += MemberService_Saved;
            }
    
            private void MemberService_Saved(IMemberService sender, SaveEventArgs<IMember> e)
            {
                foreach (var member in e.SavedEntities)
                {
                    
                  //write to the logs every time a member is saved
                  this._logger.Info<MyPublishEventComponent>("member {member} has been saved and event fired!", member.Name);
                }
            }
            public void Terminate()
            {
                //unsubscribe during shutdown
                 MemberService.Saved -= MemberService_Saved;
            }
        }
    }
    

    Events

    Event Signature Description
    Saving (IMemberService sender, SaveEventArgs e) Raised when MemberService.Saving is called in the API.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. SavedEntities: Gets the collection of IMember objects being saved.
    Saved (IMemberService sender, ContentSavedEventArgs e) Raised when MemberService.Save is called in the API and after data has been persisted.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Save method call (true by default).
    "sender" will be the current IMemberService object.
    "e" will provide:
    NOTE: See here on how to determine if the entity is brand new
    1. SavedEntities: Gets the saved collection of IContent objects.
    Publishing (IPublishingStrategy sender, ContentPublishingEventArgs> e) Raised when MemberService.Publishing is called in the API.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    "sender" will be the current IPublishingStrategy object.
    "e" will provide:
    NOTE: If the entity is brand new then HasIdentity will equal false.
    1. PublishedEntities: Gets the collection of IContent objects being published.
    Published (IPublishingStrategy sender, ContentPublishedEventArgs e) Raised when MemberService.Publish is called in the API and after data has been published.
    NOTE: It can be skipped completely if the parameter "raiseEvents" is set to false during the Publish method call (true by default).
    "sender" will be the current IPublishingStrategy object.
    "e" will provide:
    NOTE: See here on how to determine if the entity is brand new
    1. PublishedEntities: Gets the published collection of IContent objects.
    UnPublishing (IPublishingStrategy sender, PublishEventArgs<Umbraco.Core.Models.IContent> e) Raised when MemberService.UnPublishing is called in the API.
    "sender" will be the current IPublishingStrategy object.
    UnPublished (IPublishingStrategy sender, PublishEventArgs<Umbraco.Core.Models.IContent> e) Raised when MemberService.UnPublish is called in the API and after data has been published.
    Copying (IMemberService sender, CopyEventArgs<IContent> e) Raised when MemberService.Copy is called in the API.
    The event is fired after a copy object has been created and had its parentId updated and its state has been set to unpublished.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Copy: Gets the IContent object being copied.
    2. Original: Gets the original IContent object.
    3. ParentId: Gets the Id of the parent of the IContent being copied.
    Copied (IMemberService sender, CopyEventArgs<IContent> e) Raised when MemberService.Copy is called in the API.
    The event is fired after the content object has been copied.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Copy: Gets the copied IContent object.
    2. Original: Gets the original IContent object.
    3. ParentId: Gets the Id of the parent of the IContent being copied.
    Moving (IMemberService sender, MoveEventArgs<IContent> e) Raised when MemberService.Move is called in the API.
    NOTE: If the target parent is the Recycle bin, this event is never fired. Try the Trashing event instead.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the IContent object being moved.
    2. ParentId: Gets the Id of the parent of the IContent being moved.
    Moved (IMemberService sender, MoveEventArgs<IContent> e) Raised when MemberService.Move is called in the API.
    The event is fired after the content object has been moved.
    NOTE: If the target parent is the Recycle bin, this event is never fired. Try the Trashed event instead.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the moved IContent object.
    2. ParentId: Gets the Id of the parent of the IContent moved.
    Trashing (IMemberService sender, MoveEventArgs<IContent> e) Raised when MemberService.MoveToRecycleBin is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the IContent object being trashed.
    2. ParentId: Gets the Id of the RecycleBin.
    Trashed (IMemberService sender, MoveEventArgs<IContent> e) Raised when MemberService.MoveToRecycleBin is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the trashed IContent object.
    2. ParentId: Gets the Id of the RecycleBin.
    Deleting (IMemberService sender, DeleteEventArgs<IContent> e) Raised when MemberService.DeleteContentOfType, MemberService.Delete, MemberService.EmptyRecycleBin are called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. DeletedEntities: Gets the collection of IContent objects being deleted.
    Deleted (IMemberService sender, DeleteEventArgs<IContent> e) Raised when MemberService.Delete, MemberService.EmptyRecycleBin are called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. DeletedEntities: Gets the collection of deleted IContent objects.
    DeletingVersions (IMemberService sender, DeleteRevisionsEventArgs e) Raised when MemberService.DeleteVersion, MemberService.DeleteVersions are called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Id: Gets the id of the IContent object being deleted.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersionId: Gets the id of the IContent object version being deleted.
    4. IsDeletingSpecificRevision: Returns true if we are deleting a specific version.
    5. DeletePriorVersions: False by default.
    DeletedVersions (IMemberService sender, DeleteRevisionsEventArgs e) Raised when MemberService.DeleteVersion, MemberService.DeleteVersions are called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Id: Gets the id of the deleted IContent object.
    2. DateToRetain: Gets the latest version date.
    3. SpecificVersionId: Gets the id of the deleted IContent version.
    4. IsDeletingSpecificRevision: Returns true if we are deleting a specific version.
    5. DeletePriorVersions: False by default.
    RollingBack (IMemberService sender, RollbackEventArgs<IContent> e) Raised when MemberService.Rollback is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the IContent object being rolled back.
    RolledBack (IMemberService sender, RollbackEventArgs<IContent> e) Raised when MemberService.Rollback is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the rolled back IContent object.
    SendingToPublish (IMemberService sender, SendToPublishEventArgs<IContent> e) Raised when MemberService.SendToPublication is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the IContent object being sent to publish.
    SentToPublish (IMemberService sender, SendToPublishEventArgs<IContent> e) Raised when MemberService.SendToPublication is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the sent IContent object to publish.
    EmptyingRecycleBin (IMemberService sender, RecycleBinEventArgs e) Raised when MemberService.EmptyingRecycleBin is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. NodeObjectType: Gets the Id of the node object type of the items being deleted from the Recycle Bin.
    2. RecycleBinEmptiedSuccessfully: Boolean indicating whether the Recycle Bin was emptied successfully.
    3. IsContentRecycleBin: Boolean indicating whether this event was fired for the Content's Recycle Bin.
    4. IsMediaRecycleBin: Boolean indicating whether this event was fired for the Media's Recycle Bin.
    EmptiedRecycleBin (IMemberService sender, RecycleBinEventArgs e) Raised when MemberService.EmptiedRecycleBin is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. NodeObjectType: Gets the Id of the node object type of the items deleted from the Recycle Bin.
    2. RecycleBinEmptiedSuccessfully: Boolean indicating whether the Recycle Bin was emptied successfully.
    3. IsContentRecycleBin: Boolean indicating whether this event was fired for the Content's Recycle Bin.
    4. IsMediaRecycleBin: Boolean indicating whether this event was fired for the Media's Recycle Bin.
    SavedBlueprint (IMemberService sender, SaveEventArgs<IContent> e) Raised when MemberService.SavedBlueprint is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the saved blueprint IContent object.
    DeletedBlueprint (IMemberService sender, DeleteEventArgs<IContent> e) Raised when MemberService.DeletedBlueprint is called in the API.
    "sender" will be the current IMemberService object.
    "e" will provide:
    1. Entity: Gets the deleted blueprint IContent.