1

I am creating a sign-up form with WFFM and have added a "Create User" save action for the form. There is a domain field on the dialog where the create user save action is edited. Should I create a new domain specifically for these users, or just re-use "extranet" or another domain? I want to secure parts of the site, so that only logged-in (and validated) users can access them. I don't see how I would do this using only a domain - normally I would assign read access to a specific role, but don't see an option for specifying the role within the create user save action dialog.

1
  • did you try with extranet domain ? Commented Mar 23, 2017 at 12:07

2 Answers 2

2

Using roles for this requirement sounds like a good solution but by default WFFM Create User action does not support the Roles. You have more possibilities how/when to do this.

1. Assign roles manually

This is the simplest way. Just use User Manager and assign roles manually. Of course it is not really efficient to assign particular roles for every new registered user.

2. Custom assign role WFFM action

You can create your own save action and set it up on your form. The implementation will look like something like this:

using System.Web.Security;
using Sitecore.Data;
using Sitecore.Form.Submit;
using Sitecore.WFFM.Abstractions.Actions;

namespace MyProject.Feauture.Security.WFFM.Actions
{
    public class AssignRoleAction : CreateUser
    {
        public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data)
        {
            var userName = this.DomainField + "\\" + adaptedFields.GetValueByFieldID(ID.Parse(this.UserNameField));
            Roles.AddUserToRole(userName, "Your role name");
        }
    }
}

3. Assign the role on login

So you can also assign the role on login, if it's not added to your user probably based on the domain.

1

There is a built-in save action called "Edit Role Membership". This can be configured to assign the created user to the relevant role.

To do this, select the form in the content editor, click "Save Actions". From the "Save Actions" dropdown select "Edit Role Membership" and click "Add" (first screenshot). Then click "Edit" to configure the role applied to the created user (second screenshot).

enter image description here enter image description here

1
  • Nice, I did not found this :) Commented Mar 29, 2017 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.