Table of Contents

Class UserCreateViewModel

Namespace
Dynamicweb.Users.Frontend.UserCreate
Assembly
Dynamicweb.Users.dll

View model for the UserCreate frontend module.

public sealed class UserCreateViewModel : UserViewModel
Inheritance
UserCreateViewModel
Inherited Members
Extension Methods

Examples

Razor template usage:

@inherits ViewModelTemplate<Dynamicweb.Users.Frontend.UserCreate.UserCreateViewModel> @using Dynamicweb.Users.Frontend.UserCreate

@{ var action = Model.GetCreateUserLink(Pageview.Page.ID); var customers = Model.GetImpersonatableCustomerNumbers(); // available for authenticated creators }

<form method="post" action="@action"> <label for="Email">Email</label> <input type="email" id="Email" name="Email" value="@Model.Email" required />

<label for="UserName">Username</label> <input type="text" id="UserName" name="UserName" value="@Model.UserName" />

@* Optional: admin-only customer selector *@ @if (customers?.Any() == true) { <label for="CustomerNumber">Customer</label> <select id="CustomerNumber" name="CustomerNumber"> <option value="">(Same as my account)</option> @foreach (var c in customers) { <option>@c&lt;/option&gt; } </select> }

<button type="submit">Create account</button>

@if (Model.Result != UserCreateResultType.None) { <p class="form-message">@Translate(Model.Result.ToString())&lt;/p&gt; } </form>

Remarks

This model is provided to Razor templates in /Templates/Users/UserCreate/Create and to the confirmation email template in /Templates/Users/UserCreate/ConfirmationEmail. It exposes common user fields (via UserViewModel), links to login and set-password pages , the email approval link, optional group collections, and the result of the most recent create attempt).

Templates typically render a form that posts to GetCreateUserLink(UserCreateViewModel, int) and use Result to display success/error messages. When an authenticated administrator creates a user, you can optionally render a customer selector from Model.GetImpersonatableCustomerNumbers().

Properties

Gets or sets the one-time approval link used to complete activation on the Set password page.

public string? ApprovalLink { get; set; }

Property Value

string

Typically populated in the confirmation email template; null during the initial GET of the create form.

Gets or sets a resolved link to the Set password page, when configured.

public string? CreatePasswordLink { get; set; }

Property Value

string

Primarily used in the confirmation email and in error handling UI.

GroupSourceType

Gets or sets the source type for user group selection in the user creation process.

public UserCreateGroupSourceType GroupSourceType { get; set; }

Property Value

UserCreateGroupSourceType

Remarks

Indicates how selectable user groups are determined (e.g., none, from configuration, or other sources). Used to control group selection UI and logic in the frontend module.

Gets or sets a resolved link to the login page, when configured.

public string? LoginLink { get; set; }

Property Value

string

Useful for rendering a “Already have an account? Sign in” link beneath the form.

Password

Gets or sets the password posted from the create form (optional).

[SensitiveData]
public string? Password { get; set; }

Property Value

string

Remarks

Many solutions ask only for email/username here and let users set a password via the emailed ApprovalLink (recommended). Marked as sensitive; avoid echoing it back to the client.

Result

Gets or sets the outcome of the most recent create attempt.

public UserCreateResultType Result { get; set; }

Property Value

UserCreateResultType

Remarks

Use this to render success/error feedback in the create template. Defaults to None.

SelectableUserGroups

Gets or sets the user groups that can optionally be chosen in the form.

public IEnumerable<UserGroupViewModel> SelectableUserGroups { get; set; }

Property Value

IEnumerable<UserGroupViewModel>

Remarks

If you render a group selector, post the chosen IDs and the module will add them alongside any required groups from UserGroups.

UserGroups

Gets or sets the user groups that are always applied to newly created accounts.

public IEnumerable<UserGroupViewModel> UserGroups { get; set; }

Property Value

IEnumerable<UserGroupViewModel>

Remarks

Configured by editors in the paragraph app (e.g., “Groups for new users”); not meant to be changed by end users.

See Also

To top