Skip to main content
deleted 19 characters in body
Source Link
Tamás Tárnok
  • 4.3k
  • 1
  • 20
  • 33

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.CreateDisabledUser
{
    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.

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.CreateDisabledUser
{
    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.

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.

added 5 characters in body
Source Link
Tamás Tárnok
  • 4.3k
  • 1
  • 20
  • 33

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.CreateDisabledUser
{
    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.

Using roles for this requirement sounds like a good solution but by default WFFM Create User action 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.CreateDisabledUser
{
    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.

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.CreateDisabledUser
{
    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.

edited body
Source Link
Tamás Tárnok
  • 4.3k
  • 1
  • 20
  • 33

Using roles for this requirement sounds like a good solution but by default WFFM Create User action 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.CreateDisabledUser
{
    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.

Using roles for this requirement sounds like a good solution but by default WFFM Create User action 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.CreateDisabledUser
{
    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.

Using roles for this requirement sounds like a good solution but by default WFFM Create User action 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.CreateDisabledUser
{
    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.

added 65 characters in body
Source Link
Tamás Tárnok
  • 4.3k
  • 1
  • 20
  • 33
Loading
Source Link
Tamás Tárnok
  • 4.3k
  • 1
  • 20
  • 33
Loading