# Profile widget

You use the *Profile* widget to preview and edit user profile details. Depending on the widget configuration, you can use the widget for the current user or for any other user.

## Configure edit mode

1. Open the *Profile* widget designer.
2. Select the *Edit mode only* and choose what you want the system to do when profile changes are saved:

*Edit will be available in the drop down.*

## Configure read mode

1. Open the *Profile* widget designer.
2. Select *Read mode only* and choose a template.\
   By default, there is just one *ProfileEdit* template out of the box. Any other view template that exists in`~/Mvc/Views/Profile` and starts with *Read* will be available in the drop down.

## Configure both modes

To enable users to see their profiles in preview with the option to edit it, do the following:

1. Open the *Profile* widget designer.
2. Choose what you want the system to do when changes are saved:
   * *Switch to Read mode*\
     Returns the user to read mode where the changes are applied.
   * *Show a message above form*\
     Renders a simple message above the form to notify the user that the changes are applied.
   * *Open a specially prepared page...*\
     Select a Sitefinity CMS page that the user will be redirected to after saving the profile.
3. Choose a preview template.\
   By default, there is just one *ProfileEdit* template out of the box. Any other view template that exists in`~/Mvc/Views/Profile` and starts with *Read* will be available in the drop down.
4. Choose an edit template.\
   By default, there is just one *ProfileEdit* template out of the box. Any other view template that exists in`~/Mvc/Views/Profile` and starts with *Edit* will be available in the drop down.

## Advanced configuration

1. To set up the *Profile* widget to display the profile of a specific user:
   1. Fill out the *UserName* field with the user name of the user
   2. If the user is from a non-default membership provider, modify *MembershipProvider*

2. Specify how profile properties are bound to the form using the *ProfileBindings* property:

   ```JSON
   [
     {
       "ProfileType": "Telerik.Sitefinity.Security.Model.SitefinityProfile",
       "Properties": [
         { "Name": "FirstName", "FieldName": "FirstName", "Required": true },
         { "Name": "LastName", "FieldName": "LastName", "Required": true },
         { "Name": "About", "FieldName": "About" }
       ]
     }
   ]
   ```

3. If you have a custom field for the User profile widget, use this snippet to display and access the field in the widget view template:

   ```Razor
   @model Telerik.Sitefinity.Frontend.Identity.Mvc.Models.Profile.ProfilePreviewViewModel
   @using Telerik.Sitefinity.Frontend.Identity.Mvc.Models.Profile;
   @using Telerik.Sitefinity.Frontend.Mvc.Helpers;

   <div class="@Model.CssClass">
     <img src="@Model.AvatarImageUrl" alt="@Model.UserName" width="100" height="100" />
     <h3>@Model.DisplayName</h3>
     <p>@Model.Email</p>
     <p>@Model.SelectedUserProfiles.FirstOrDefault().Fields.CustomFieldName</p>
   </div>
   ```

   In the code above, replace the `CustomFieldName` with the actual name of the custom field.

4. If you have a custom field for profiles that you want to be editable, add it in the *Properties* collection just like the default fields. The model of the profile widget will have a *Profile* dictionary containing the properties that are mapped in the *ProfileBindings*, like the one below:\
   `@Html.TextBoxFor(u => u.Profile["FirstName"])`
