Page 1 of 1

Extending $customer and inherited class list

Posted: Sat Oct 27, 2007 7:31 pm
by nviusguy
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

Posted: Mon Oct 29, 2007 9:14 am
by Logan Rhodehamel
1) Keep in mind that roles are assigned to users indirectly, via group memberships.

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
2) You can use the "UserSettingsCollection" class, corresponding to the ac_UserSettings table. C# code might look like this:

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");
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.