When you try to adapt Sitefinity to your specific scenario – one things that I found important is the ability to add extra properties to the user profile. For example we may want to add Employeed ID or Title.
We start with the web.config of the sitefinity web application and add our properties right under the following few lines of code:
| <properties> |
| <add name=“FirstName” /> |
| <add name=“LastName” /> |
We add:
<add name=“TestField” type=“System.String”/>
Where we have the type and the name of the field. Then we access “[YourProject] \Sitefinity\Admin\CmsAdmin\Users.aspx” and find the placeholders to place our actuall contros that will handle the value, like this:
<asp:TextBox ID=“TestField” runat=“server”></asp:TextBox></li>
To access the field anywhere else in your code and get/set value to it … you can use the following code:
| UserManager manager = new UserManager(); |
| IList cmsUsers = manager.GetUsersInRole(“administrators”); |
| foreach (string user in cmsUsers) |
| { |
| ProfileBase userProfile = ProfileBase.Create(user); |
| string fieldValueSomething = (string)userProfile.GetPropertyValue(“TestField”); |
| Response.Write(fieldValueSomething+“<br />”); |
| } |