Copied to clipboard

Flag this post as spam?

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


  • andles 44 posts 64 karma points
    Feb 10, 2011 @ 04:29
    andles
    0

    Bulk Delete Members

    I have a large number of members in test system - nearing time to lauch and want to delete them. I would have though that the blow would suffice - but the whole system seems to just hang with no action taken:

     

    IEnumerable<umbraco.cms.businesslogic.member.Member> allMembers = umbraco.cms.businesslogic.member.Member.GetAllAsList();

                foreach (umbraco.cms.businesslogic.member.Member m in allMembers)
                {
                    Membership.DeleteUser(mu.UserName);
                    SATUtilities.LogInfo("Deleted!");

                }

    Also, using the .Net Membership API Membership.GetAllUsers() is returning nothing (empty collection) when I try to do the delete using thsi api.

    Is there a preferred way to go about a task such as this?

    Cheers,

    Andles

     

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 10, 2011 @ 07:21
    Jan Skovgaard
    0

    Hi Andles

    Would'nt you be able to delete the users directly from the database? Must admit that I'm not sure how many tables you need to look at but just a thought...

    /Jan

  • andles 44 posts 64 karma points
    Feb 10, 2011 @ 07:28
    andles
    0

    I probably could - and I have a list of 6 tables I belive are involved  / affected. But I'm a bit nervous about doing this in case it upsets things somehow, and I'm also curious to know why the simple code based approach above won't work.

    (I actually found a sql script in the old forums to do this - but it was aimed at version 3 when I'm on 4.5.)

    I may do a back of db, and try it out the sql way if  I get no responses on my original approach. Thanks for your input, much appreciated.

    Cheers,
    Andles.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Feb 10, 2011 @ 10:34
    Richard Soeteman
    1

    HI Andies,

     

    The Member.GetAlll method slows you down. What you could do is use the MemberExport package (in batches of 200 records if you want to use the free version) which exports the MemberIds. Load this file and then use the API call New Member(memberid).Delete(); to delete the members

    Hope this helps you,

    Richard

     

  • Masood Afzal 176 posts 522 karma points
    Feb 10, 2011 @ 10:48
    Masood Afzal
    0

    You can get memberIds using following sql query and then use new Member(memberid).Delete() method (as noted by Richard):

    SELECT nodeId AS MemberId FROM cmsMember
  • andles 44 posts 64 karma points
    Feb 11, 2011 @ 00:36
    andles
    0

    Thanks Masood / Richard as this was the way to go. I did look at the MemberExport package but it seemed no point using due to such a simple query doing the exact same thing.

    A better Member Manaegement too (and completely free) is : http://our.umbraco.org/projects/backoffice-extensions/blackpoint-member-admin

    Wish I'd have found that sooner!

    Not sure if it does export - but this is pretty much a straightforward sql query anyway.

     

     

Please Sign in or register to post replies

Write your reply to:

Draft