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.

Does the gform_notification_email filter still work?

  1. I just upgraded WP and Gravity Forms on one of my sites and now the customised email notifications have stopped working. Emails are now sent to Notification to Administrator -> Email field instead of the post author as intended using the hook below.

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

    Is the above code still the preferred method for changing notifications to the post author?

    Posted 13 years ago on Sunday April 17, 2011 | Permalink
  2. I think the filter is boken in some way, because when I change it to this, it stills fails. I.e. it still reverts to admin email field and not bob@example.com.

    add_filter( 'gform_notification_email_3', 'route_notification', 10, 2 );
    function route_notification($email_to, $entry) {
       //global $post;
       //$email_to = get_the_author_email();
       $email_to = 'bob@example.com';
       return $email_to;
    }
    Posted 13 years ago on Sunday April 17, 2011 | Permalink
  3. I'm unable to replicate this issue with v1.5.1.1, the filter is working as expected. One thing I would suggest is to check your spam filter if you are doing tests and not receiving the email at a @gmail.com account, because gmail could have flagged it as spam because it didn't originate from gmail.

    Here are screenshots of what I did to try and replicate this, everything worked fine and as expected:

    Screenshot of code in place in functions.php:
    http://grab.by/9Uru

    Screenshot of User Notification settings:
    http://grab.by/9Urz

    Screenshot of form being submitted:
    http://grab.by/9Urx

    Screenshot of notification being received at address specified by filter:
    http://grab.by/9UrB

    Nobody else is reporting this issue which leads me to believe that your tests aren't working properly because they are getting caught in a spam filter, or there is other code on your site that is causing the problem. The filter is working as expected.

    Posted 13 years ago on Monday April 18, 2011 | Permalink
  4. OK, one major difference, is that I originally had my code in single.php, I've now moved it to functions.php. Things have improved slightly, now the following code works:

    add_filter( 'gform_notification_email_3', 'route_notification', 10, 2 );
    function route_notification($email_to, $entry) {
    	global $post;
    	//$email_to = get_the_author_email();
    	$email_to = 'bob@example.com';
    	return $email_to;
    }

    Where as the following code fails completely:

    add_filter( 'gform_notification_email_3', 'route_notification', 10, 2 );
    function route_notification($email_to, $entry) {
    	global $post;
    	$email_to = get_the_author_email();
    	//$email_to = 'bob@example.com';
    	return $email_to;
    }

    I don't think get_the_author_email() is working for some reason. What's the best way to see if it's being set properly? I'm not quite sure how to echo out variables from filters...

    Posted 13 years ago on Monday April 18, 2011 | Permalink
  5. Give this code a shot:

    http://pastie.org/1807801

    Posted 13 years ago on Monday April 18, 2011 | Permalink
  6. That worked! Is get_the_author_email defunct now?

    Posted 13 years ago on Monday April 18, 2011 | Permalink
  7. Looks like it has been deprecated: http://codex.wordpress.org/Function_Reference/the_author_email . Could well be effecting other users with custom notification functions copied from Gravity support forums.

    Posted 13 years ago on Monday April 18, 2011 | Permalink