Skip to content

<UpdateUser>

After a form submits successfully, updates an existing DNN user identified by UserId. Only the properties you set are touched — properties left off the tag are left unchanged on the user record. Custom DNN profile properties can be set via <Property> child tags.

Validate user input — and lock the form down

The form must verify that the current user is allowed to edit the target UserId. Without that check, anyone who can reach the form could overwrite anyone else's profile.

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>
  <SelectCommand CommandText="SELECT @UserId AS UserId">
    <Parameter Name="UserId" Value="[[User:Id]]" DataType="Int32" DefaultValue="-1" />
  </SelectCommand>
  <UpdateUser Email="[[Email]]"
              FirstName="[[FName]]"
              LastName="[[LName]]"
              UserId="[[UserId]]" />
  <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 colspan="2"><AddButton Text="Save" /> <CancelButton Text="Cancel" /></td>
    </tr>
    <tr>
      <td colspan="2"><ValidationSummary DisplayMode="BulletList" HeaderText="Errors:" CssClass="NormalRed" /></td>
    </tr>
  </table>
  <TextBox Id="txtUserId" Visible="False" DataField="UserId" DataType="Int32" />
</AddForm>

Properties

Required

PropertyValuesDefaultDescription
UserId *integer | tokenThe DNN UserID of the user to update

User profile

Set only the properties you want to change. Properties left off the tag (or set to an empty string for most fields) are left untouched.

PropertyValuesDescription
EmailemailNew email address
FirstNamestringNew first name
LastNamestringNew last name
DisplayNamestringNew display name
ApprovedTrue FalseWhen set, toggles the user's approved flag
UpdatePasswordOnNextLoginTrue FalseWhen set, toggles the prompt-on-next-login flag
CountrystringDNN profile: country
RegionstringDNN profile: region/state
CitystringDNN profile: city
PostalCodestringDNN profile: zip / postal code
StreetstringDNN profile: street address
UnitstringDNN profile: unit / apartment
TelephonestringDNN profile: telephone

Password change

To change the user's password, supply both OldPassword and NewPassword — DNN requires the existing password to authorize the change.

PropertyValuesDescription
OldPasswordstringThe user's current password
NewPasswordstringThe replacement password

Error messages

PropertyDefaultNotes
ErrMsgUserNotFound"Unable to locate user with ID of '{0}'"{0} is replaced with the supplied UserId
ErrMsgInvalidPassword"Invalid or incorrect password supplied"Thrown when the password change fails
ErrMsgOther"An error occurred while trying to update user with ID of '{0}'"Catch-all. {0} is replaced with the supplied UserId

* Required property

Child Tags

TagRequiredDescription
<Property>optionalSets a custom DNN profile property on the 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 | tokenNew value

Property Details

  • UserId: The DNN-assigned UserID of the account to update. Use [[User:Id]] to update the currently logged-in user, or a field token bound to a hidden <TextBox> to update the user identified by the form's data. The value must parse to an integer; otherwise ErrMsgUserNotFound is thrown.