Developer forum

Forum » Development » Include User Custom Field Data in Email Receipt from Forms for Editors

Include User Custom Field Data in Email Receipt from Forms for Editors

Tim Eddings
Reply

Hi,

Looking for some help on how I might include User Field and User Custom Field data values in the email receipt sent when a visitor submits a Forms for Editors form.

When the Visitor or User (not logged in to the frontend) fills out and submits the form, I have code in the form template that creates a User (if one doesn’t exist), writes values to the standard user fields, and writes values to several user custom fields (code generated data that is not submitted by the user).  I need to be able to include some of the data from the typical user fields as well as the user custom fields in the email receipt back to the visitor/user.

The issue I’m running into is that it looks like the processing of the form and the sending of the receipt email may be asynchronous, as the values for the newly written data in the user fields (standard and custom) are always blank in the receipt email (but are written correctly to the AccessUser fields).  I have custom code in the email receipt template that retrieves the user field values and seems to work if the user exists and the fields have values prior to the submission of the form in question.  I just don't seem to be able to get the new values written at the time of the submission.

Is there a way to ensure the values are written to the user fields before the email receipt is sent?

Dynamicweb version 9.10.5

Thank you,

Tim

 


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Tim,

 

Looks like you want to populate form fields and you're just doing them later in the stack. There are a few ways you can do this:

  1. If you can populate your fields through Javascript, maybe you can populate the hidden fields before submitting the form
  2. Use a Form Nofication subscriber https://doc.dynamicweb.com/api-docs#article=e65d43d9-d4fd-dc90-ea0a-7ef859b9e4b1
    There are a few that may work for you depending if you want to move some of your current logic to a dll OR keep it where you have it
    1. OnAfterSubmit
    2. OnBeforeSendMail

 

Best Regards,

Nuno Aguiar

 
Tim Eddings
Reply

Hi Nuno,

Thanks for the quick reply and the ideas.  I'll dig into these and see what I can come up with.

Tim

 

 

You must be logged in to post in the forum