Hello,
A few questions:
1> What is the best way to extend ($customer). We have a multi-tiered subscription model and have new user roles:
Free Registration
Subscriber (has purchased 1 or more subscriptions, set on checkout of a subscription)
Premium Subscriber (has purchased 1 or more subscriptions with a premium attribute)
and want to create new functions like $customer.getRoles or $customer.IsSubscriber.
2> What is the best way to extend the registration/checkout section to add profile additions/value pairs via UserAttributes table, and be able to extend this to call and set these? Is there underlying functionality not documented/exposed to do this, or do we need to make a class and data handling to do this?
3> In addition, we have run into several cases where there are references to objects where we don't have the benefit of knowing what the reference is. Can you point us to the right files that set the reference for customer and/or do you have an SDK snippet that would list out the common attributes/functions on these? It would really help to be able to look them up in VS.
Thanks in Advance!
--ron
Extending $customer and inherited class list
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
1) Keep in mind that roles are assigned to users indirectly, via group memberships.
2) You can use the "UserSettingsCollection" class, corresponding to the ac_UserSettings table. C# code might look like this:
The keys for the user settings must be unique.
3) Check this thread:
viewtopic.php?t=5511
It's basically just a listing of all the classes, methods, and properties. We have to update our process to generate the help documentation to work with a new tool, so the descriptions are missing.
Code: Select all
<b>Check for role:</b><br>
#if ($User.IsInRole("MyRoleName"))
You are in my role
#else
You are not in my role
#end
<br><br>
<b>Roles I am in:</b><br>
#foreach($userGroup in $User.UserGroups)
#set ($group = $userGroup.Group)
#foreach($groupRole in $group.GroupRoles)
$groupRole.Role.Name<br>
#end
#end
Code: Select all
//SET A VALUE
User currentUser = Token.Instance.User;
currentUser.Settings.SetValueByKey(key, value);
//READ A VALUE
string favoriteColor = currentUser.Settings.GetValueByKey("favorite color");
3) Check this thread:
viewtopic.php?t=5511
It's basically just a listing of all the classes, methods, and properties. We have to update our process to generate the help documentation to work with a new tool, so the descriptions are missing.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.