3341 Posts in 982 Topics by 703 members
|Go to End|
3 September 2013 at 6:29am
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
6 November 2013 at 9:11am
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.
6 November 2013 at 10:43am
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.
|Go to Top|