Skip Navigation

[Resolved] How to set custom field into post form notifications 'to:' field

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by roulartaM 5 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1520953
contact-email-notification.PNG

Tell us what you are trying to do?
I have two custom post types: 'Nieuwbouwprojecten' (EN = 'projects') and 'Contacten' (EN = 'contacts'). Here are some important custom fields attached to it:

NIEUWBOUWPROJECTEN
- Contact mail company (Email)

CONTACTEN
- First name (Single line)
- Last name (Single line)
- Phone (Phone)
- E-mail address (Email)
- Message (Multiple lines)

Those 2 post types are linked with a one-to-many relationship:
Nieuwbouwprojecten [0 .. 1] << Contacten [*]

I've made a view to show a bunch of 'nieuwbouwprojecten' and a single page to show more info about a single 'nieubouwproject'. Within that single page, there's a post form so you can get in touch with the owner of that project.

The fields in that post form are identical to the custom fields attached to the post type 'contacten'.

When a user send the form, all the data is stored and linked correctly in the database as I expected. So far so good!

THE PROBLEM

When the form is submitted, I want to send an email to the owner of the projects. So I need the value of that "Contact mail company" custom field loaded into 'Send notification to a specific email address'. I've tried a couple of things but none of them are working.
My best attempt: [types field='contact-mail-bedrijf' output='raw'][/types]

See screenshot "contact-email-notification.png"

When I complete the form and send it, no mail goes to the emailaddress. Perhaps I've used a wrong code? Can you help me with this please?

----------

Is there any documentation that you are following?
I've read en tried the feedback from Minesh in this topic: https://toolset.com/forums/topic/create-contact-form-per-custom-post-type/

----------

What is the link to your site?
hidden link

#1521195

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for getting in touch.

Is this custom field on the form itself ? If so then you can select the option "Send to an email specified in the form".

From there you can select the custom field that the email is coming from.

The field you've currently select only accepts text inputs and shortcodes are not processed here.

Thanks,
Shane

#1524531
nbz.jpg

Hi Shane,

Thanks for your reply! Unfortunately, the custom field is not coming from the form. Note that the posted form data goes into the "Contacten" custom fields. The parent post type ("Nieuwbouwprojecten") single page have that "emailaddress" custom field and holds that form.

Perhaps there's another way to send a notification to that e-mailaddress where I wasn't thinking about?

Grtz,
Sam

#1525199

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Given that the page itself holds the email then you can get the email address into the form.

For this you will need to add a generic email field to your form, then for the value of that field you will use the types shortcode that is used generate the output on the page.

Finally save the form and then you should be able to setup the email notifications to be sent based on this field value.

Thanks,
Shane

#1531813

Thanks Shane, you've pointed me in the right direction. I managed to send the email to the right email address!
For others who have the same problem, here's the code I used in my notification mail:

<div style="display: none;">
[cred_generic_field type='email' field='input-field-that-holds-the-address']
{
"required":1,
"persist":1,
"validate_format":0,
"default":"[types field='input-field-that-holds-the-address' output='raw'][/types]"
}
[/cred_generic_field]
</div>