Copied to clipboard

Flag this post as spam?

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


  • Peter Cort Larsen 388 posts 922 karma points
    Jun 26, 2014 @ 13:49
    Peter Cort Larsen
    0

    Member.AfterSave

    Hi,

    Before i could call my own custom method, when the member is saved.

    I understand that it has been changed in 7.14.

    Something with 'MemberService.Saving'

    Do anyone have an example, i cant seem to find any?

  • Dan Lister 416 posts 1973 karma points c-trib
    Jun 26, 2014 @ 16:19
    Dan Lister
    101

    Hi Peter,

    Below is an example of the Saving event and setting a member property value:

    using Umbraco.Core;
    using Umbraco.Core.Events;
    using Umbraco.Core.Models;
    using Umbraco.Core.Services;
    
    namespace MyApplication.Events
    {
        public class MemberSavingEvent : ApplicationEventHandler
        {
            public MemberSavingEvent() 
            {
                MemberService.Saving += MemberServiceOnSaving;
            }
    
            private static void MemberServiceOnSaving(IMemberService sender, SaveEventArgs saveEventArgs)
            {
                foreach (var member in saveEventArgs.SavedEntities)
                {
                    member.SetValue("propertyAlias", "value");
                }
            }
        }
    }

    Thanks,
    Dan. 

  • Peter Cort Larsen 388 posts 922 karma points
    Jun 26, 2014 @ 20:12
    Peter Cort Larsen
    0

    Perfect, thanks

  • Petr Snobelt 923 posts 1534 karma points
    Sep 09, 2014 @ 14:16
    Petr Snobelt
    0

    Hi is it possible to notify user if I cancel (e.Cancel = true) the event? I try throw application exception, using standart umbraco notification looks better.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies