Dynamically "send to email" notification

Hello,

Looking for help :slight_smile:

Summary:
Trying to create 1 form on multiple pages and have it email notifications dynamically send to the suppliers email

Details:

i am creating a directory
this directory will have multiple suppliers with their own page and contact popups
( see test page https://hostevents.com.au/supplier/hire-a-chef-catering/ )

I see current options are:

  • Create a new form for each page
  • Having conditional logic in the notifications for each page to the form
    Both these after a few hundred suppliers will be difficult to manage

Instead of creating a new form for every supplier page or conditional logic, i would like to see how i can integrate 1 form on all pages with the notification dynamically adding a suppliers email address though the notifications ā€œsend to emailā€

Is this possible?

TIA

Iā€™d look for a way to save the supplier email as a meta field on their specific page. You could then use the gform_notification filter to set the to email. Something like the following should work once you have a way to save the meta as supplier_email.

<?php

add_filter( 'gform_notification', function( $notification, $form, $entry ) {

   $notification['to'] = get_post_meta( get_the_ID(), 'supplier_email' );

   return $notification;

}, 10, 3 );

Use one form for all the different supplier pages. Donā€™t make multiple forms.

If you can store the supplier email in the post meta for the post (this is key) you can also do this:

Add an email field to the form. Give it a default value of {custom_field:supplier_email} (assuming you stored their email address in a custom field with the meta key ā€˜supplier_emailā€™). You can make this field hidden if you want to, so itā€™s not shown on the front end of the form.

Then, you can select this email field in your ā€œSend Toā€ for the notification. Select the ā€œSelect a fieldā€ radio button, then select your ā€œsupplier emailā€ field in the dropdown. That will populate the notification with the email address that was pulled from the post custom field.

Either way should work. If you need any other ideas, please let us know.

1 Like

How do I keep forgetting about that {custom_field:} merge tag? Super handy!

1 Like

Thanks @uamv & @chrishajer for your fast replies.

i want to have the business meta on the page. So this will work a treat :slight_smile:

Already using custom fields so this should be easy once i get the meta data up

If i have any issues ill reach back out, otherwise thank you

2 Likes