Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Question regarding Member and Decorators


Go to End


3 Posts   1009 Views

Avatar
JonC

Community Member, 8 Posts

11 October 2011 at 6:40pm

Edited: 11/10/2011 6:44pm

Hi, I'm not sure if this is the right place to ask this question (and if it isn't, I'm very sorry).

I'm currently trying to create a site with a lot of members-based functionality - the site isn't accessible without a member login at all, and has (currently) two levels of functionality for different levels of membership. One of the things the site has to do is allow a member to transition between different types of member: the base case is that a normal user may upgrade themselves into a user with more privileges.

The issue I'm having is that the upgraded users need to be sorted separately from the standard users, and that some things may only apply to each user category individually.

From ssbits and the documentation on the main site, I gather it's possible to add decorators to Member itself in order to extend functionality to members: is it then possible to treat the decorated and un-decorated Members as separate classes (after applying the decorator with a form?), or would I have to create two separate classes extending Member?

Avatar
MarcusDalgren

Community Member, 288 Posts

11 October 2011 at 9:08pm

The thing is that a decorator applies to the class so all members get decorated, not just a few.
You might be better off using groups to signify different levels of privilege (which is what groups are for) and use a decorator to add custom fields and functionality to the member class if you need it.

Avatar
JonC

Community Member, 8 Posts

12 October 2011 at 6:18pm

Thanks for the information! So, I would have all the extra functionality simply check if a member is a member of a certain group, or else forbid the action, and have the second (or higher) levels of user, which require extra data compared to a normal member, be present as a Members decorator, simply not populated or used within the standard Member object?

That is simpler than I thought. Is there documentation beyond the base API of how to work with user groups and user-based stuff like Members adding new instances of certain DataObjects with forms, and so on? I'm a newbie and not quite used to SS, forgive me if this is common knowledge.