PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamically populate Send To Email field?

  1. I've been struggling to figure out how to dynamically populate the Send To email address for notifications. Is this even possible?

    Ideally, I'd like to use a WP custom field to assign an email address to the page that contains the form and then when the user submits the form it will be sent only to the address in the custom field. The reason I want to do this is I will need to have the same form appear on a bunch of different pages but have it send to a different email address depending on the page.

    Thanks.

    Posted 14 years ago on Wednesday May 26, 2010 | Permalink
  2. Yes, this is possible to do and there is another thread that addresses almost exactly what you want to do. The post talks about sending the email to the author of the post. Just rework the code to pull the email from a custom field instead.

    Here is the thread:

    http://forum.gravityhelp.com/topic/sending-form-to-author-of-post

    Posted 14 years ago on Wednesday May 26, 2010 | Permalink
  3. Thanks! That worked great. The only code I needed was:

    add_filter( 'gform_notification_email_1', 'route_notification', 10, 1 );
    function route_notification($email_to) {
    	global $post;
    	$email_to = get_post_meta($post, 'email_address', true);
    	return $email_to;
    }
    Posted 14 years ago on Wednesday May 26, 2010 | Permalink

This topic has been resolved and has been closed to new replies.