Jump to:

3377 Posts in 1001 Topics by 714 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Custom member: Extending Member or Dataobject

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

Page: 1
Go to End
Author Topic: 431 Views
  • finrod
    Avatar
    Community Member
    5 Posts

    Custom member: Extending Member or Dataobject Link to this post

    Hello,

    I am pretty new to SilverStripe and have the following situation.

    I want to create a "CustomMember" data model. This "CustomMember" can login on the site (not in the CSM!) and do some actions.

    On http://doc.silverstripe.org/framework/en/reference/member I read the following

    Class Member should just be extended for entities who have some kind of login.

    In my case CustomMember has some kind of login, even though not on the CSM. Currently I've implemented my CustomMember like so

    class CustomMember extends DataExtension

    Is this the correct way or should I instead extend Member like so

    class MyMember extends Member


    ?

  • Antsb
    Avatar
    Community Member
    7 Posts

    Re: Custom member: Extending Member or Dataobject Link to this post

    Extend Member is the correct way of doing it. Once you have done this, and you create new instances of your MyMember class, they will each have a corresponding row in the Member table in the DB with the same uid as the row in the MyMember table.

    Extending Member gives you the ability to use the standard logOut(), checkPassword() etc functions on your MyMember as well as retrieving him like normal through the Member::currentUser() method to get the logged in Member.

    I've just implemented this recently with a custom login form and it works well.

  • Antsb
    Avatar
    Community Member
    7 Posts

    Re: Custom member: Extending Member or Dataobject Link to this post

    Sorry, should clarify what I said "extending Member is a good way of doing it" instead of "the correct way" - I know that it works really well for me.

    To prevent them from being able to log in to the CMS, you just make sure they aren't in the Administrator user group. You could create a special group for these types of users if you want to group them.

    431 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.