Form Actions‎ > ‎

User

User Login

Action Form allows you to require the user to be logged in to submit the Action Form, this a case when you have a multi-step form. You can also use Action Form as an Login module, it's very simple just by using the predefined Login Form template - this is a simple form with username and password fields which logs the user in. Note that the form must contain the Username and Password fields in order for the User Login action applied on the button to work.   

User Registration

Action form allows you to specify an action for creating user account when the user submits the form. To apply this action, the form must have at least an email address field. The Action Form sets the email address as the username. This option is only applicable for new users. User Registration Options:
  • Email as Username 
    Select this option to create the user account using the email address provided. This option will use the email address if you do not have the username field on the form. If you do not want to use the email address for the user name you will need to provide the username field for your form.

  • Generate random password
    Select this option to generate a random password. This generates a random password if you do not provide a password field on the Action Form. If you do not want to generate a random password you will need to create a password field for your form.

  • Send standard DNN registration email
    Select this option to send the standard DNN registration email. If you do not want to send DNN registration email and would like a custom email template, you will need to set-up Email actions.

  • Login if user already exists
    Select this option if the user exists in the system. The user will be logged in if the user authentication matches.

Update User Profile

Action Form allows you to set up some actions so that the users can update their profile information. It is a very useful option when your site has an intranet section. Update User Profile options:
  • Allow password update
    For this option to work, you need to set-up a password field for you Action From. This option is useful when a user would like to update his password. 
  • Also update Display Name with
    For this option to work, you need to set-up a First Name and Last Name field for you Action From. This option will give the user the ability to change his display name with one of the two options: First Name and Last Name. 

A practical example would be to populate the profile property from a registration form when a new user is created and to do this you need to add on the button the Update Profile action which will match every field or data you have on your form with a profile property, this includes data that you load with SQL action, Inject Data actions or others, the match is done by title and ID.

Grant User Role

Action form allows you to assign additional roles to an user as well as an expiration date per each role. Grant User Role options:
  • Role
    This option allows you to grant a security role - all the user roles created in admin page is displayed in the drop down list from where you can select. 
  • Other Role Names
    This option give you the possibility to input a role name and if you specify multiple role names, separate them by comma. It also accepts DNN tokens and My Tokens. 
  • Role expiration (days)
    In this filed you can set a period to determine after how many days the role expires. It you leave it blank, it will never expire. 

Revoke User Role

This action can be used to cancel a security role from a specific user.  From the Role drop down list you have the possibility to select the role you want to revoke (this data is fetched from the Admin > Security Roles page). 


Non-administrators to manage other users' profile

Scenario: 

Set view and edit permissions to users with "test" role; 

on the grid 
1. create a page with the grid that uses as datasource an SQL statement with select * from Users 
2. on Edit URL post the URL of the form on which you want to make the user changes www.site.com/form-page.aspx?UserID=[UserID] 
3. add an edit item button with datasource refresh action 

on the form 
1. add a text box with Initial value [Profile:FirstName] 
2. add Email, Password, and Confirm Password field 
3. submit button with actions: 
Load User with user identifier set to [QueryString:UserId] 
Update User Profile with Allow password update option checked + update email with Email field 
4. On Preinit set Load User action with [QueryString:UserId] in User identifier 

When you log in with "test" role and click on the Edit item button on the grid, the form page loads the user id in the query string and populates the field where you put on the initial value the profile token, and whenever you change the email address and the password, the user you edit the data on updates correctly the email and the password. 


Update DNN Username 


To do this, you can use a stored procedure. In the example below, we'll use email address as username:


input: @currentemail, @newemail

declare @userguid uniqueidentifier;

set @userguid = (select top 1 userid from aspnet_Users where UserName=@currentemail);

update aspnet_Users set UserName = @newemail, LoweredUserName = LOWER(@newemail) where UserId = @userguid;

update aspnet_Membership set email=@newemail, LoweredEmail=lower(@newemail) where UserId = @userguid;

update users set username=@newemail , email= @newemail where userid=@userID