Developer forum

Forum » CMS - Standard features » Assign user to group on Form submit

Assign user to group on Form submit

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys, 

I am using Forms for editors on DW 9.6.3 and I need to assign a user to a group upon form submit.

The user is authenticated, fills out the form (which has Name and Email mapped correctly to user properties) and my expectation would be to assign the user to a group specified in the Paragraph settings.

According to the documentation, if the "Create user on form submit" is checked and a group selected, it should assign the existing user to the group and set Email permissions to true. I don;t need the Email permission check but I need the group assignment.

In my situation it does not happen.

I have checked the template tags rendered for the form and they don't contain any mention of the UserGroup.

What am I doing wrong?

Thank you,
Adrian 


Replies

 
Nicolai Pedersen
Reply

The feature is called "Create user on form submit" - meaning it will create a user. You want to update a user...? But overwrite name and email fields? That is not supported by forms.

But why use a forms for editor for that? The user is already logged in - so you would make an edit profile with options - i.e. which groups they should be member of etc.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Based on the documentation here: https://doc.dynamicweb.com/documentation-9/content/apps/forms-for-editors I should be able to assign the user to a group (if I understand the explanation correctly):

  • If the email corresponds to an existing user, only the email permission field and group membership is updated. This makes it possible to sign existing users up for newsletters. You cannot update other fields this way - use the Extranet app.

I don't want to edit the email nor the Name. I just want to assign the user to a new group, ask for some Consents and send a notification to the Admin of the site (because the Admin will have to perform a task afterward)

The extranet will allow assigning the user to a group, and maybe collecting a consent. But it will not allow sending the notification to the admin.

What am I missing?

Adrian

 
Nicolai Pedersen
Reply

That is related to the same (anonymous) user (that would be email address) is submitting the same form where the "Yes I want newsletter" checkbox. Not sure the group code runs without the email permissions set as it is meant for users signing up to newsletters when they are already in the userdatabase.

But in order for that to work, you might have not defined the email field on the form? Using the autovalue is not enough - you also need to choose the email field under the settings for the form. Try to check that and see if it then works without the email permission field.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Email is already set. I also get the confirmation email once I submit the form.

I don't mind if the Email permission will be checked. My main concern is the allocation to the Group and it does not seem to work.

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Anything else on this topic?

Thank you,
Adrian

 
Nicolai Pedersen
Reply

Nope - discussed this with another partner last week, and will do something in order to be able to create a user 2 times, but not more.

Until then, create a flow like this

Create profile

  1. Enter Email: np@dynamicweb.dk, press "next"
  2. Yeah, you already have a profile - go to login or rest your password here <- link to reset password page
    or
  3. Please enter your name etc.

This happens even on Facebook...

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you very much for your answer. 

Is not my use case, but at least I know I should find a different solution.

In my situation, a user needs to fill out a form in order to request an upgrade of his level. The upgrade of the level would be performed manually by an admin. But in order to ease the work of the admin, upon completion of that Form, I would assign the user to a "requested Upgrade" User group. This way, the admin can go in the folder and decide who should be upgraded.

I wanted to use Forms for editors for this purpose because I also want to capture some comments from the user requesting the upgrade as well as some uploaded files backing the request. I cannot use the Extranet for this purpose because of the above reasons.

That's why I was hoping that the "Create user on submit" would do the job. At least that was my understanding of the feature description.

If that's not possible, I will have to find other ways to handle this feature.  

Thank you,

Adrian

 
Wiktor Wieczorek
Reply

Hello, anything new regarding this functionality?
I have a newsletter form and when an email is not in the database it checks the Email permission:

But when an email is already used it adds the user to my "Newsletter" group but it doesn't update the Email permission :(

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Using forms for editors?

 
Wictor Wieczorek
Reply

Yes

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

On the form you have a checkbox "Signup for newsletter" or something - on that checkbox, ensure that you have "email permission" set as an autovalue.

Also ensure that on the paragraph that you have "Create user on submit" enabled.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Oh - is the user already logged in?

The form will use the email field on the form to locate the user - and not take the current logged in user.

 
Wictor Wieczorek
Reply

Yes, it happens when the user is logged in, actually when they are not logged in it works because the value of the field is not false:

When they log in and they don't have permissions the value is false:

It's because it is taking automatic value from the users' Email permission field

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Well - it is kind of the point :-). As the value is false on that user....

And now that you have a signed up user, why can you not use a "Edit profile" page with just this one checkbox - and a heading called "Signup for newsletter" instead of "Edit profile"? Why do you need to use "Create user" feature in forms for a user that is already created?

I can of course force allow email to be set to true if submitted - but it is kind of buggy... And then what if the checkbox is not set? Should I then remove the AllowEmail or ignore it? The latter also a bit buggy... Sorry for thinking out loud. But  I am just trying to understand how you want create user to work....

 
Wictor Wieczorek
Reply

Okay, I see your point, in that case, I probably have to make another form for logged-in users and show this one if the user is logged in.
Thanks for the help Nicolai! 😎

 

You must be logged in to post in the forum