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 change FROM email for user notification

  1. I was wondering if there is a way to dynamically change the FROM email address for a user notification for a form. I would like to have the from address match the TO email address for the admin notification, which I have set up using the routing feature for the admin notification. In the documentation I only see filters for changing TO email addresses.

    Posted 11 years ago on Monday June 4, 2012 | Permalink
  2. David Peralty

    There isn't currently a way to change the from address to match the TO address in either type of notification we provide.

    Posted 11 years ago on Monday June 4, 2012 | Permalink
  3. Dangit! I was really hoping I was going to find an answer to this.

    Posted 11 years ago on Wednesday October 24, 2012 | Permalink
  4. I think it is possible to change the "From" address. See the documentation on the notification here:

    http://www.gravityhelp.com/documentation/page/Notification

    You could use the gform_pre_submission_filter: http://www.gravityhelp.com/documentation/page/Gform_pre_submission_filter

    In the example on that page, you can change the "From" email address by changing line 14 to this:

    [php]
    // this presumes that input field 4 holds the email
    // address you want to use as the FROM
    // address for the admin notification
    $form['notification']['from'] = rgpost('input_4');

    or

    [php]
    $form['notification']['from'] = 'scott@sellinggreaterlouisville.com';

    Does that accomplish what you're looking for?

    Posted 11 years ago on Thursday October 25, 2012 | Permalink
  5. I don't think so. I'd like to have the user notification email to be able to be changed. Not the from email for the admin.

    Posted 11 years ago on Thursday October 25, 2012 | Permalink
  6. So you would like to make the From address for the User notification identical to the From address for the Admin notification? Is that accurate? You can do it in the same manner, but instead of

    [php]
    $form['notification']['from'] = rgpost('input_4');

    you would do something like

    [php]
    $form['autoResponder']['from'] = $form['notification']['from'];

    Documentation for the autoResponder (user notification):
    http://www.gravityhelp.com/documentation/page/AutoResponder

    Posted 11 years ago on Thursday October 25, 2012 | Permalink
  7. Chris, how would I go about doing this for all forms on a site? Would I have to tie this into one of the hooks?

    Posted 11 years ago on Thursday October 25, 2012 | Permalink
  8. You would use the gform_pre_submission_filter as I mentioned here. Your code will look like this:

    [php]
    add_filter('gform_pre_submission_filter', 'admin_email_from');
    function admin_email_from ($form) {
        $form['autoResponder']['from'] = $form['notification']['from'];
        // return the modified form object
        return $form;
    }

    Using the filter that way will apply to all forms on your site.

    Posted 11 years ago on Thursday October 25, 2012 | Permalink
  9. Thanks for this solution.

    Posted 11 years ago on Wednesday November 7, 2012 | Permalink
  10. You're welcome.

    Posted 11 years ago on Thursday November 8, 2012 | Permalink

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