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.

Issues populating with author email

  1. Referencing the code examples in this post: http://www.gravityhelp.com/forums/topic/sending-form-to-author-of-post I'm still having issues.

    This is what I'm using:

    add_filter( 'gform_notification_email_2', 'route_notification', 10, 2 );
    function route_notification($email_to, $entry) {
    	global $post;
    	$email_to = get_the_author_email();
    	return $email_to;
    }

    Now, theoretically, even if the system isn't sending the emails, the ENTRIES should show the populated (author email) field right? I even tried defining a hardcoded email to $email_to. Nothing.

    I used Jan's suggest code snippet in the aforementioned thread but I'm not sure which parameter I'm supposed to be passing to the form field. $email_to, gform_notification_email_2 or route_notification (none of which work).

    The form I'm testing this with is found here: http://metrostudentmedia.com/next_metradio/shows/a-game2

    Please advise on both questions.

    Posted 11 years ago on Wednesday February 23, 2011 | Permalink
  2. The hook above doesn't populate a field, it's only used for sending the notification. It's a hook for changing the Send To on the notification. So no, it wouldn't be reflected in the form entry itself.

    Here is another example of hardcoding the user notification send to address that works. If isn't working, then the code isn't being implemented properly your forms just aren't sending emails which is typically a server configuration issue.

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

    BTW the example above changes the Send To for *ALL* forms.

    If you do gform_notification_email_2 that changes the Send To for form id 2. So the _2 on the end of gform_notification_email is a specific form id to apply that code to.

    The way your code example is written it is using gform_notification_email_2 which means it's applying that customization ONLY to form id 2. Whichever form that is.

    Posted 11 years ago on Wednesday February 23, 2011 | Permalink
  3. OK, I think I'm following you.

    I can't hardcode the email because it has to be dynamic to the page/post author. So is there any way to test-populate the TO field without actually sending the email? My email server is lousy at best and most of the time doesn't send anything at all. I'm trying to get this working before we change hosts.

    Posted 11 years ago on Wednesday February 23, 2011 | Permalink
  4. The code you have above should populate the send to with the post author. But as I mentioned it was configured to only do so for form id 2.

    You probably do want to make it form specific so having the _2 on the end of the filter call is the way to go because you probably don't want ALL your forms doing this, just that specific form... whichever it may be.

    You can get the correct form id for the form from the Edit Forms list page.

    Posted 11 years ago on Wednesday February 23, 2011 | Permalink
  5. Ironically, the ID for my form IS 2. I just wanted to know if there was a way to test that the author email is IN FACT getting populated without the system ever actually sending the email. Creation of an entry is what I'm looking for. The entry should list the populated value even if an email isn't sent.

    So how can I populate a field with the author email so it shows up on the entry?

    Posted 11 years ago on Wednesday February 23, 2011 | Permalink
  6. Here is a post that discusses dynamically populating a field using php:

    http://www.gravityhelp.com/forums/topic/pre-populate-form-with-user-data#post-13628

    You can follow the same steps and customize the example code in that post only populate the value with the post author like you are doing in the code you already have for populating the notification email send to address.

    Posted 11 years ago on Wednesday February 23, 2011 | Permalink
  7. Thanks Carl! Love what you guys have built here.

    Posted 11 years ago on Wednesday February 23, 2011 | Permalink