User

The User field makes it possible to select one or more users or user groups when creating an item (Figure 1.1). You can then render information about the selected user(s) in frontend.

When adding this field to an item type, you can specify if the editor will select Users or User groups – the default is users (Figure 1.2)

When an item with a user-field is rendered in frontend, you can access a collection of UserViewModels via the GetUsers-method:

RAZOR
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> <div class="col-md-12 card card-spaced"> <h3>Users</h3> @{ var userlist = Model.Item.GetUsers("User"); } <div> @foreach (var user in userlist) { <div><b>Name:</b> @user.Name</div> <div><b>Address:</b> @user.Address</div> <div><b>Address2:</b> @user.Address2</div> <div><b>City:</b> @user.City</div> <div><b>Country:</b> @user.Country</div> <div><b>ID:</b> @user.ID</div> <br /> } </div> </div>