Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

UserForm to send out unique/dynamic email subjects?


Go to End


4 Posts   2042 Views

Avatar
Mohammed

Community Member, 25 Posts

4 February 2011 at 4:56am

We are using the UserForm module. Is there a way for the form e-mail subject to contain user submitted data? We need each e-mail that is submitted using an online form to contain a unique subject so the form response does not get incorrectly grouped. (When using Google's Gmail "Conversation View", emails of the same subject/topic are grouped together)

If someone know's of a workaround, please let us know. That would be awesome!

Avatar
Ryan M.

Community Member, 309 Posts

4 February 2011 at 1:39pm

In code/UserDefinedForm.php, on line 592, edit this:

$email->setSubject($recipient->EmailSubject);

You could do something like this:

$email->setSubject($recipient->EmailSubject." - ".$submittedFields->find('Name', 'EditableTextField1')->Value);

In order to find the field you want to insert, you'll have to do this a few lines above:

print_r($submittedFields); die();

And do a test submit of your form to get the raw data and pick out the name of the field you want to use in the email subject.

Avatar
Mohammed

Community Member, 25 Posts

8 February 2011 at 9:36am

I tried to make the changes you suggested, however, I was not able to get it to work...Do you have any other ideas? :-/

Avatar
Ryan M.

Community Member, 309 Posts

9 February 2011 at 12:18pm

Edited: 09/02/2011 12:18pm

Well, why didn't it work? Paste your code here and let's see, and don't forget to mention which form field you are trying to use in the subject.