Skip to content

<AddUser>

After a form submits successfully, registers a new user in DNN with the supplied profile information. Optionally adds the user to one or more security roles via RoleNames, and sets custom profile properties via <Property> child tags.

Validate user input — and lock the form down

Public registration forms are a target for abuse. Always validate the form's inputs and protect the form so only the audience you intend can submit it.

Passing the new UserID downstream

On success, XMP adds a __UserId token (two underscores + UserId) to the form data, so later action tags (e.g. <AddToRoles>, <Redirect>) can reference the new user by ID. Available since v4.1.

Action timing

Action tags only run when the form submits successfully. They evaluate their tokens at that point — not when the form loads — so [[FieldName]] tokens read user input. Actions run in document order; an action that fails throws away every action listed below it.

Example

html
<AddForm>
  <AddUser RoleNames="Role1,Editors" Email="[[Email]]"
           FirstName="[[FName]]" LastName="[[LName]]"
           Username="[[Username]]" Password="[[Password]]" />
  <table>
    <tr>
      <td>
        <Label For="txtFirstName" Text="First Name" />
        <TextBox Id="txtFirstName" DataField="FName" DataType="String" />
        <Validate Type="Required" Target="txtFirstName" Text="**" Message="First Name is required." />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="txtLastName" Text="Last Name" />
        <TextBox Id="txtLastName" DataField="LName" DataType="String" />
        <Validate Type="Required" Target="txtLastName" Text="**" Message="Last Name is required." />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="txtEmail" Text="Email" />
        <TextBox Id="txtEmail" DataField="Email" DataType="String" />
        <Validate Type="Required" Target="txtEmail" Text="**" Message="An email address is required." />
        <Validate Type="Email" Target="txtEmail" Text="**" Message="Please enter a valid email address." />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="txtUsername" Text="Username" />
        <TextBox Id="txtUsername" DataField="Username" DataType="String" />
        <Validate Type="Required" Target="txtUsername" Text="**" Message="Please enter a Username." />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="txtPassword" Text="Password" />
        <Password Id="txtPassword" DataField="Password" DataType="String" />
        <Validate Type="Required" Target="txtPassword" Text="**" Message="A Password is required." />
      </td>
    </tr>
    <tr>
      <td colspan="2"><AddButton Text="Add" /> <CancelButton Text="Cancel" /></td>
    </tr>
    <tr>
      <td colspan="2"><ValidationSummary DisplayMode="BulletList" HeaderText="Errors:" CssClass="NormalRed" /></td>
    </tr>
  </table>
</AddForm>

Properties

Required

PropertyValuesDefaultDescription
Username *stringUnique username for the new account
Email *emailThe new user's email address
FirstName *stringThe new user's first name
LastName *stringThe new user's last name
Password *stringPassword for the new account

User profile

PropertyValuesDefaultDescription
DisplayNamestring(FirstName + LastName)Name displayed throughout DNN. If omitted, defaults to "FirstName LastName"
ApprovedTrue FalseFalseWhen True, the user is auto-approved and can log in immediately
UpdatePasswordOnNextLoginTrue FalseFalseWhen True, the user is prompted to change their password at first login
CountrystringCountry (mapped to DNN profile)
RegionstringRegion/state (mapped to DNN profile)
CitystringCity (mapped to DNN profile)
PostalCodestringZip / postal code (mapped to DNN profile)
StreetstringStreet address (mapped to DNN profile)
UnitstringUnit / apartment (mapped to DNN profile)
TelephonestringTelephone (mapped to DNN profile)
RoleNamescomma-listOne or more DNN role names. The new user is added to each
SendVerificationEmailTrue FalseFalse(Ignored as of v4.6.) DNN now sends the verification email automatically based on the portal's registration mode

Error messages

When DNN rejects the user creation, <AddUser> throws an action error using one of these messages. Override them to localize or customize the wording.

PropertyDefault
ErrMsgDuplicateEmail"The email address already exists"
ErrMsgInvalidEmail"The supplied email is invalid"
ErrMsgInvalidPassword"The supplied password is invalid"
ErrMsgInvalidUsername"The supplied username is invalid"
ErrMsgDuplicateUser"The user is already registered"
ErrMsgDuplicateUsername"The username already exists"

* Required property

Child Tags

TagRequiredDescription
<Property>optionalSets a custom DNN profile property on the new user

<Property>

Sets a single custom profile property. Use one <Property> tag per property to set.

AttributeValuesDefaultDescription
Name *stringProfile property name (must already exist in DNN)
Valuestring | tokenValue to assign
html
<AddUser Email="[[Email]]" Username="[[Username]]" Password="[[Password]]"
         FirstName="[[FName]]" LastName="[[LName]]">
  <Property Name="Biography" Value="[[Bio]]" />
  <Property Name="Twitter"   Value="[[TwitterHandle]]" />
</AddUser>

Property Details

  • DisplayName: The name DNN shows in places like the user menu and post bylines. If omitted (or empty), <AddUser> builds it from FirstName and LastName.

  • RoleNames: A comma-delimited list of DNN security role names. After the user is created, <AddUser> adds them to each named role. For more control (start/end dates, custom delimiter, conditional adds), use a separate <AddToRoles> action with the [[__UserId]] token.