Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Completely Delete a Member

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2298 Views
  • Gargo
    Avatar
    Community Member
    5 Posts

    Completely Delete a Member Link to this post

    Hy there

    I'm asking myself how i can completely delete a Member. If i remove a Member in the Security Group of the CMS it is only removed from the Group but the Member itself still exists.
    I plan to build a sort of social networking site and if a Member wish to delete himself (or i wish to delete a member) this should not be a problem at all.

    How can i do this (basic) task in SilverStripe?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Completely Delete a Member Link to this post

    Hi Gargo

    You could always use a SQL Query to delete the dataset you want. Something like this:

    $query = new SQLQuery('*', array('Member'), 'ID = ' . $MemberId);
    $query->delete = true;
    $query->execute();

    Where $MemberId is your Member-ID. For further information about the SQLQuery Class, read here: http://doc.silverstripe.com/doku.php?id=sqlquery

  • Gargo
    Avatar
    Community Member
    5 Posts

    Re: Completely Delete a Member Link to this post

    thank you for your reply.

    seems to be a bad solution cause in this case relations aren't handled correctly. or did i miss something?
    furthermore i'm looking for a way to delete Members in the CMS (as easy as i can add them).

    maybe the delete() Method on the Member object would do it?

    a member based administration interface like "Security" would be nice.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Completely Delete a Member Link to this post

    I'm not sure where the Member is referenced elsewhere. AFAIK only groups are being referenced for permissions, and since you're already removing the member from the group this shouldn't be too much of a problem. I could be wrong though.
    Maybe you can extend/modify the SecurityAdmin class to fit your needs?

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Completely Delete a Member Link to this post

    You can call destory() on any object which I think will handle relations etc.

  • Gargo
    Avatar
    Community Member
    5 Posts

    Re: Completely Delete a Member Link to this post

    Shouldn't this feature get it's way into the standard implementation of silverstripe?
    I think this is a basic administration task which shouldn't be made by each one itself.

  • Gargo
    Avatar
    Community Member
    5 Posts

    Re: Completely Delete a Member Link to this post

    I just tried it out to manage the Member deletion with a ModelAdmin implementation.
    Relations are ignored. For example the Records in the Group_Members Table will be keept alive ...
    Maybe i have to decorate the onBeforeDelete Function by myself ...

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: Completely Delete a Member Link to this post

    Added $member->destroy(); to /cms/code/MemberTableField.php @ line 246 to fix this issue in SilverStripe 2.4.5.

    2298 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.