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 in the email notifcaiton (a dynamic URL in the email)

  1. Hi team,
    I want to create a dynamic URL on the basis of 3 fields in my gravity form.

    Like if the ABC is selected from a drop down, append the value to https://xxxx.com/xyx/
    then append another value to above url ... something like this.
    and i want to embed the final URL in the notification email to the user.

    any idea where can i do that?
    sorry i m new for gravity form :)

    Regards,
    J

    Posted 11 years ago on Tuesday November 13, 2012 | Permalink
  2. I can't see from your example exactly what you are trying to do. Can you post again with more specifics?

    In your user notification area, you can use merge tags, which will hold the values which were submitted by your form. Take a look at the confirmation tab of the form settings and pull down the merge tabs drop down to see what is available to you. You can stack them right next to each other, and when the form is submitted and the confirmation is displayed, the merge tags you used will be replaced by the values submitted with the form. This could be the URL in the confirmation area (the merge tags were not typed but were inserted by selecting from the drop down):

    http://example.com/{This drop down:2}{Another field name:4}{entry_id}

    And in the confirmation shown to the visitor. they might see this:

    http://example.com/woolnone371

    Where "wool" was the value from drop down #2, "none" was the value for field 4, and the entry ID was 371.

    Posted 11 years ago on Tuesday November 13, 2012 | Permalink
  3. Sorry for being so short, let me explain a bit. I understand what you are saying thats what i am already doing. What i need is, to have a dyanamically created url embeded in the autoResponder. Currently i am sending {all_fields}, which is working fine. I need another field in the email which will have a dynamically created URL.

    so i need different if and else in order to generate that URL. i do now where to write this hook code?
    I mean where to write the add_filter ?
    Please guide.
    thanks

    Posted 11 years ago on Tuesday November 13, 2012 | Permalink
  4. Hey there,
    Just wana do something like this, but i want to know which file i have to write the code :-

    add_filter('gform_pre_submission_filter_1', 'conditional_message');
    function conditional_message($form){

    $link = 'http://test.com/test/app?&z=#CURRENCYCODE#p=#PRICE#&bs=Yes&u=#USER#&r=SPP';

    $currency = rgpost('input_7');
    $price = rgpost('input_8');
    $user = rgpost('input_9');

    if($currency == 'AU')
    $ccode = 'askdfhksahdfk';

    if($currency == 'US')
    $ccode = 'gsdlllllsaaa';

    $link = str_replace("#CURRENCYCODE#",$ccode,$link);
    $link = str_replace("#PRICE#",$price,$link);
    $link = str_replace("#USER#", $user,$link);

    // my modified form for autoResponder
    $form['autoResponder']['message'] .= "$link";

    // return modified form
    return $form;
    }

    Posted 11 years ago on Tuesday November 13, 2012 | Permalink
  5. David Peralty

    So you are both looking for where to put the code? If so, check out:
    http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F

    Posted 11 years ago on Tuesday November 13, 2012 | Permalink
  6. I have added the filter in functions.php ...
    everything seems working fine now...
    just another concern, now i have a custom transaction ID which i generate during the notification in the function conditional_message($form) {
    $my_transactiion_id = mytechnique to generate id;
    //i send email here with my custom format
    }
    is there any way if i can save this transaction id into gravity form transaction ID?

    Urgent help is required please ...

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  7. David Peralty

    If you want your own transaction ID, then you'll need to create a hidden field and push the data to that hidden field.

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  8. Hi Sir,
    Can you please write an example what will be the quickest way?

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  9. David Peralty

    I can't because I am not sure how you would want to build and store your transaction numbers. You know that each submission does get an entry ID though, right, and that it automatically increments?

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  10. Thank you sir. here is my example

    conditional_message($form) {
    $my_transactiion_id = mytechnique to generate id; (10 digitis long randomly generated)
    // my modified form for autoResponder
    $form['autoResponder']['message'] .= "$link";
    // return modified form
    return $form;
    }

    I want to add $my_transactiion_id in the transaction_id field of gravity table. is there any quickest way can you please write a quick example? this will help me thank you.

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  11. David Peralty

    The transaction_id field is one used by the e-commerce sites (Paypal and Authorize.net). You could create your own Transaction ID field, and populate that field with your generated ID.

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  12. Ok sure i am gona create a new field, but is there any already built in function in gravity to push the data into table? or i have to do it myself?

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  13. David Peralty

    You will use the pre-submission filter again with a different function. The function will just take your generated transaction ID and put it in the field.

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  14. I would appreciate if you can send me any example link as i am generating ID in the above function i am using which is post submission

    Posted 11 years ago on Wednesday November 14, 2012 | Permalink
  15. Enrico, thank you for your post. That will help me to do what i need.

    To generate a random ID, you can do a function with time, date, client IP (use str replace to delete dots)

    function generateID(){
    	$a = date('dmY');
    	$b = date('his');
    	$c = str_replace('.', '', $_SERVER['REMOTE_ADDR']);
    	$d = mt_rand();
    	$generatedid = md5($a.$b.$c.$d);
    	return $generatedid;
    }
    
    add_action("gform_pre_submission", "pre_submission_handler");
    function pre_submission_handler($form){
        $_POST["input_14"] = generateID();
    }

    This will give you a short example.

    Posted 11 years ago on Thursday November 15, 2012 | Permalink
  16. Great!
    thanks team.

    Posted 11 years ago on Friday November 16, 2012 | Permalink
  17. Thank you fcbinfo, for the snippet.

    Posted 11 years ago on Saturday November 17, 2012 | Permalink

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