Accessing/render merge tag data in notification['message'] using gform_notification [RESOLVED]

I have a piece of code using gform_notifications that is being used to move the notification information out of GF and into SendGrid. I suppress the email send and send the email via SendGrid in a unique template I have made. It also has the opt out links attached to it.

The issue is the email sent via SendGrid contains the merge_tags as text and not their value. See the snippet below. How can I get $notification[‘message’] to render here? What hook does it render?

    add_filter( 'gform_notification', 'check_supress', 10, 3 );
    function check_supress( $notification, $form, $entry ) {    
   // all kinds of other stuff happens here prepping for SendGrid/////
   $email1, "My Name" ,
     [
      "body" => $notification['message'],
      "image_1" => $thumb,
      "url" => $url,
      "subject" => $notification['subject']
     ]
    // Send Grid then sends the email using the variables above. Only issue is merge tags in subject and message are not values..
   }

Hey!

Run $notification['message'] through the GFCommon::replace_variables() method. You would use it like this:

   add_filter( 'gform_notification', 'check_supress', 10, 3 );
    function check_supress( $notification, $form, $entry ) {    
   // all kinds of other stuff happens here prepping for SendGrid/////
   $email1, "My Name" ,
     [
      "body" => \GFCommon::replace_variables( $notification['message'], $form, $entry )
      "image_1" => $thumb,
      "url" => $url,
      "subject" => \GFCommon::replace_variables( $notification['subject'], $form, $entry ),
     ]
    // Send Grid then sends the email using the variables above. Only issue is merge tags in subject and message are not values..
   }

Hope that helps!

1 Like

Bullseye! Thanks @Jake_Jackson

2 Likes

@Jake_Jackson GOAT

1 Like
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.