Copied to clipboard

Flag this post as spam?

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


  • Niels Lynggaard 190 posts 548 karma points
    May 19, 2020 @ 13:07
    Niels Lynggaard
    0

    Deleting member groups.. Trying to remove all members on "Deleting"

    Hi all.

    Our client is extensively using member groups to handle access to limited content. However, once in a while they want to clean up a bit and remove user groups.

    This, however, isn't possible when the group is used by members.

    So, I've been trying to create an eventhandler that hooks into the Membergroupservice.deleting event... But to my surprice, this isn't what's being hit!

    The error message in the backoffice I get when I try to delete a group, says; "The role Test is currently assigned to members" .... at at Umbraco.Core.Services.MemberService.DeleteRole....

    AHA, not groups, but "Roles".

    So My handler hooking into MemberGroupService.Deleting isn't even being hit...

    Now, what I really want to do is hook into this event, get all members from that group and remove each member from the group and continue with the delete.

    But now I'm confused. There's no "MemberRoleService" or similar?

    Any ideas on what I should hook into?

    Alternatively, i'd have to implement either a by-group (role?) bulk-editor to remove users first, or a custom way to delete groups that uses MemberService.DeleteRole without throwing, but that seems a bit far off.. and also, I'm not sure of the consequences..

    Any ideas on how to enable the client to delete member groups (and in the process, hopefully removing members from that group) would be most welcome & appreciated!

    Nb! We're using Umbraco 7..

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Aug 16, 2023 @ 08:56
    Simon Dingley
    0

    Did you resolve this? I am currently trying to do something similar on a v7 site. I am prevented from deleting the group which is the desired outcome but would be good to be able to hook into the event.

    I have a feeling that the MemberGroupService.Deleting is not firing because it doesn't get that far due to the exception being thrown before it.

Please Sign in or register to post replies

Write your reply to:

Draft