<AddToRoles>

New to Version 4.0! The AddToRoles tag will add a user to one or more DotNetNuke security roles after the form has been successfully submitted.

Syntax

<AddToRoles
    Culture="locale-id"
    EndDate="date"
    If="basic conditional equality expression"
    RoleNames="comma-delimited list of DNN roles"
    StartDate="date" 
    UserId="integer" 
/>

Remarks

 

Back to top

Example

In the example below, we're using a <Variable> tag to retrieve the current user's ID and make it available to the <AddToRoles> tag. The variable has a name of "uid" and we set the UserId property of the <AddToRoles> tag to [[uid]].

<AddForm>
  <Variable Name="uid" Value='[[User:Id]]' />

  <SubmitCommand CommandText="INSERT INTO Users(FirstName, LastName) VALUES(@FirstName, @LastName)" />
  <AddToRoles RoleNames="Role1,Editors" UserId='[[uid]]' />
  <table>
    <tr>
      <td>
         <Label For="txtFirstName" Text="First Name" />
         <TextBox Id="txtFirstName" DataField="FirstName" DataType="string" />
       </td>
    </tr>
    <tr>
      <td>
        <Label For="txtLastName" Text="Last Name" />
                 <TextBoxId="txtLastName" DataField="LastName" DataType="string" />
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <AddButton Text="Add"/> <CancelButton Text="Cancel"/>
      </td>
    </tr>
  </table>
</AddForm>
Back to top