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.

PHP Notification question

  1. webferret
    Member

    I have successfully entered the email filter into my functions php file

    add_filter( 'gform_notification_email_2', 'route_notification', 10, 2 );
    function route_notification($email_to, $entry) {
    global $post;
    $email_to = get_post_meta($post->ID, 'author_email', true);
    return $email_to;
    }

    it emails the custom filter email but i would still like to be also notified of new form entries. how can i send a notification to the custom field AS WELL as myself? thanks

    Posted 13 years ago on Friday July 9, 2010 | Permalink
  2. If you are using the filter to do this you would have to hardcode the additional email in this code. You would send multiple email addresses as the email_to value. So in your example above you would need to append ",your@email.com" as part of the $email_to value.

    Posted 13 years ago on Friday July 9, 2010 | Permalink
  3. webferret
    Member

    OK adding my email to that code messes up my site. give a error and site goes blank. this is what i did. let me know if its right, thanks

    add_filter( 'gform_notification_email_2', 'route_notification', 10, 2 );
    function route_notification($email_to, $entry, myemail@gmail.com) {
    global $post;
    $email_to = get_post_meta($post->ID, 'author_email', true);
    return $email_to;
    }

    Posted 13 years ago on Friday July 9, 2010 | Permalink
  4. Nope, you put your email address in the wrong place. It doesn't go in the function call declaration, you are supposed to append it to the end of the email_to variable that the function call defines. It should look something like this:

    $email_to = get_post_meta($post->ID, 'author_email', true) . ",your@email.com";

    Notice I have appended the email to the email_to variables. Make sure there is a comma before the hardcoded email address with no space in between the comma and the hardcoded email address.

    Posted 13 years ago on Friday July 9, 2010 | Permalink
  5. webferret
    Member

    Ok, it worked. although both emails are in the to address when emails are sent. It looks like this

    from MySite <noreply@mysite.com>
    reply-to info@fromaddressenteredonform.com
    to person@customwordpressfilter.com,
    me@appendedemail.com<<<<<<<<<<<<<<<would like this not to show when sending email to customers
    date Fri, Jul 9, 2010 at 4:58 PM
    subject blah blah blah
    mailed-by gator1561.hostgator.com<<<<<<<<<<<<<<<<<how to get rid of

    Thanks for all your support. you guys are great

    Posted 13 years ago on Saturday July 10, 2010 | Permalink
  6. We are doing this the complicated way. Remove that custom code.

    Every form has an Admin Notification and a User Notification. Edit the Notifications for that form and you can configure one or both of these.

    The User Notification is sent to the user. The Admin Notification is sent to you. Both are configurable. So you setup the Admin Notification to go to your address.

    If for some reason you also want the User Notification to go to you then you can use the BCC field on the User Notification and enter your email address there. Although the Admin Notification should suffice.

    Posted 13 years ago on Saturday July 10, 2010 | Permalink
  7. webferret
    Member

    I dont think that would work. i run a business directory. And the user posts are entered by me. I have a custom field where i enter the email of the business. People then go to the site and fill out a form to contact that business. As of now users can contact those businesses thru the form. but i would like to be notified without the business seeing my email when they get a message from a user filling out the form.

    Posted 13 years ago on Saturday July 10, 2010 | Permalink
  8. The PHP code snippet you were using just sets the Send To Address. You can still use the BCC field on the Notifications setup so that you receive a copy of the email. That is what the BCC is there for.

    So you use the PHP code snippet you were using to set the Send To address based on your custom field, and then edit the Notification setup for that form and enter your email address in the BCC field. It should then blind carbon copy you on that email.

    Posted 13 years ago on Saturday July 10, 2010 | Permalink