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.

Change notification email from short code

  1. I've seen something kind of similar in the forums:
    http://www.gravityhelp.com/forums/topic/dynamically-populate-to-email-address-for-form-within-short-code

    But my issue is slightly different.

    I've built a Wordpress template file that runs a directory of members seperate to the WordPress site. for each member I want to include a contact form powered by GF. There are over 500 members. I was wanting embed the same Gravity form so that it appears on each members' page.

    I was hoping to just use a shortcode but I can use a GF function. How do I change the notification email within a function or a shortcode? The email address is already set as a PHP variable but is set from a non-WordPress included file.

    Posted 12 years ago on Saturday July 7, 2012 | Permalink
  2. David Peralty

    What I might do is put the e-mail address into a hidden field, and then using the notification_email hook, create a function to grab the current e-mail from that field and use it for the notification.
    http://www.gravityhelp.com/documentation/page/Gform_notification_email

    Posted 12 years ago on Saturday July 7, 2012 | Permalink
  3. OK, this kind of makes sense. However I'm not only a Gravity Forms Noob I am also fairly new to WordPress. Could you unpack a few things for me? It might even help some poor lost souls in the future!

    When you say put the email address in a hidden field I assume you mean adding that to the function call to Gravity Forms. I didn't know you could add extra fields. Can you tell me where I can find out more info on that? I am assuming I could just pass the PHP string to populate the hidden part of the form? The only problem with this is that I don't want to make the members' email address public. Yes, it is only viewable in the source, but I don't think the members would be comfortable with that. The whole point of having a contact form is to stop us from having to make the email address viewable.

    In the documentation page you linked to, does the add_filter bit go in my functions.php file and the function change_notification_email go on the page with the form?

    Thanks!

    Posted 12 years ago on Saturday July 7, 2012 | Permalink
  4. In the linked documentation, the "add_filter" and the function "change_notification_email" both go into your theme's functions.php file.

    Posted 12 years ago on Sunday July 8, 2012 | Permalink
  5. Thanks.

    However if I put this code into my functions.php file:

    <?php
    add_filter("gform_notification_email", "change_notification_email", 10, 2);
    function change_notification_email($email, $entry){
       return "test@test.com";
    }
    ?>

    How do I update the email address from the template file that includes the gravity form? It would be really awesome if the documentation page gave some real examples as I don't see how I can implement the function.

    Posted 12 years ago on Thursday July 12, 2012 | Permalink
  6. Sounds like you have one template which has code to create an individual page for each member? And you want to use one form for all members, but you need the notification to go to the member where the form was embedded? And the email address is stored in a variable which is accessible when you view the member's profile or page, and that is the same page where the form is embedded? Is some of that correct?

    How do you access the member's email address on the page where the form is embedded. However that is done, we need to take that email address and populate the notification email address.

    Please show us how you can access the member's email address and we will show you how to use that to change the notification email address.

    Posted 12 years ago on Thursday July 12, 2012 | Permalink