|Number of votes:||0|
This article will give some examples of how to work with attributes on users in the EPiServer Community. Attributes can also be used on other objects in the commnuity, such as blogs, but this will not be discussed here.
To get it possible to work with an attribute, you must first add it. Click on the Attributes link in the Community tab. You will get this dialog:
I will here create an attribute “ServiceIdentifier” of type string for the IUser class. It will now be possible to set this attribute on all users.
It is also possible to create custom attribute types. You can read about it here: http://world.episerver.com/en/Articles/Items/Creating-a-Custom-EPiServer-Community-Module---Attribute-Data-Types/
I will here set a guid to this newly created attribute. CurrentUser is a property of type IUser.
You can create very advanced queries to search for users. The method IsServiceUser checks if there exists a user with the attribute “ServiceIdentifier” set to the value of guid. I don’t know know fast this kind of queries are on a huge number of users. Does anyone know?