Copied to clipboard

Flag this post as spam?

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

  • Sebastian Müller 1 post 71 karma points
    Apr 23, 2024 @ 08:14
    Sebastian Müller

    Get added member roles before persisting in the saving event.

    Hello everyone,

    The project I am currently working on requires me to check the roles that were added before the _memberService.Save() gets called. I need to perform a check and cancel the operation if the check fails.

    Currently I am working on a solution using the MemberSavingNotification, but I am unable to find a way to retrieve the newly added roles on the IMember.

    private readonly IMemberService _memberService;
    public MemberSavingNotificationHandler(IMemberService memberService)
        _memberService = memberService;
    public void Handle(MemberSavingNotification notification)
        foreach (IMember entity in notification.SavedEntities)
            // only gives already saved roles ... not the ones just added in backoffice
            IEnumerable<string> roles = _memberService.GetAllRoles(entity.Id);

    I also tried using the AssignedMemberRolesNotification Notification, but it seems to fire after the member has been saved because it doesent allow me to cancel the operation.

Please Sign in or register to post replies

Write your reply to: