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.

hook for mail notification text

  1. elinet
    Member

    Hi,
    I need to change the notification mail (user and admin) dynamically according to a specific date.
    Example:

    if current date time > di 1/10 i must change a text in the notification mail.

    How can i do?
    I don't find any hook that allows it.

    Regards

    Marco

    Posted 12 years ago on Wednesday October 3, 2012 | Permalink
  2. You can use the gform_pre_submission filter to change the notifications based on your code or rules. http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    Here is how you would change the AutoResponder (user notification):

    [php]
    add_action('gform_pre_submission', 'change_message');
    function change_message($form) {
        if ('Sunday' == date('l') {
            $body = "Today is Sunday.  We will respond to your inquiry on the next business day.";
        }
        else {
            $body = "Thank you for your inquiry.  Someone will respond to you within 6 hours.";
        }
        $form['autoResponder']['message'] = $body;
        return $form;
    }

    That code will go in your theme's functions.php http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F

    Posted 12 years ago on Wednesday October 3, 2012 | Permalink
  3. elinet
    Member

    Hi,
    i try to use this hook and change the notification message with
    "$form['autoResponder']['message']"
    But i don't see any modify..
    In the email that arrives to the user and the admin i find only the text that i write in the notification settings of gravityforms..

    I put the code in the function.php as usual.

    Any idas?

    Regards

    Marco

    Posted 12 years ago on Wednesday October 10, 2012 | Permalink
  4. @Marco, please show us the code you are using to change the user notification. If the code is lengthy, please use pastebin.com or pastie.org. Please share the URL to the page with the form as well.

    The $form['autoResponder']['message'] will change only the user notification, not the admin notification.

    Posted 12 years ago on Wednesday October 10, 2012 | Permalink
  5. elinet
    Member

    Only for testing if i can modify the notification,
    I tested the code you suggested me, without conditional clauses.

    [php]
    add_action("gform_pre_submission_7", "pre_submission");
    
    function pre_submission($form){
    	$form['autoResponder']['message'] = "<strong>test test test</strong>";
        return $form;
    
    }

    On the user notify i don't read the "test test test" message...

    Posted 12 years ago on Thursday October 11, 2012 | Permalink
  6. Instead of gform_pre_submission try gform_pre_submission_filter. I may have given you bad advice the first time around. Please let us know if this works. I'll go back and edit my original reply if this works for you.

    Posted 12 years ago on Thursday October 11, 2012 | Permalink
  7. elinet
    Member

    We are getting closer ..
    Now it works but is completely replaced all of the text of the user notification message..

    Is there any global variable that contains the standard message set with the tool of gravityforms?
    If I can use it, i concatenate this global varible to the new message..

    example:

    add_action("gform_pre_submission_filter_7", "pre_submission");
    
    function pre_submission($form){
    	global $notification; // i suppose the name :)
        $form['autoResponder']['message'] = "<strong>test test test</strong>
    
    ".$notification;
    
        return $form;
    }
    Posted 12 years ago on Friday October 12, 2012 | Permalink
  8. There is no global notification message. However, if you would like to add your text to the notification which is in the form builder, try this (append to the autoResponder rather than replace it completely:

    [php]
    function pre_submission($form) {
        $message = $form['autoResponder']['message'];
        $form['autoResponder']['message'] = "<strong>test test test</strong>\n\n" . $message;
        return $form;
    }

    That will add your custom text before the notification you set up in the form builder. If you want the notification from the form builder first, and your text after, do this instead:

    [php]
    function pre_submission($form) {
        $form['autoResponder']['message'] .= "\n\n<strong>test test test</strong>";
        return $form;
    }

    I think you have it now :-)

    Posted 12 years ago on Friday October 12, 2012 | Permalink
  9. elinet
    Member

    It works.

    Is there a way to add the message even in the admin notification?
    Because the same notification must be read by the user and by the admin(administrative secretaries)

    Thank you!

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink
  10. the message

    What message? You want to add some text to both the user notification and admin notification, but you would still like the notifications to be different? If you wanted, you could BCC the secretary on the user notification, but that is only if you want the secretary to have a copy of the user notification. If you want the secretary to have an admin notification, but you want to add text there, like you did with the user notification, just change:

    $form['autoResponder']['message']
    to
    $form['notification']['message'].

    The admin notification is referred to as "notification" and the user notification is referred to as "autoResponder".

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink
  11. elinet
    Member

    Good!
    It all works!
    i only wanted that the secretary have an admin notification, like the text i add to the user notification.

    Thanks for everything!

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink
  12. You are welcome. Glad that is working like you want.

    Posted 12 years ago on Tuesday October 16, 2012 | Permalink

This topic has been resolved and has been closed to new replies.