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.

Adding a link to a dynamic Confirmation Message

  1. CraigTommola
    Member

    I am trying to add a link in confirmation message, however my confirmation message is generated by the functions.php file, based on the selection made in input_1
    (based on this: http://www.gravityhelp.com/forums/topic/mathematics-to-gravity-forms)

    but the link won't work - based on the " after href=, I presume.
    Any directions on how to add a URL into this:

    case 1: $_POST['input_23'] = nl2br("Product Name\r\nBuy them here");
    break;

    so that the words "Buy them here" have a link around them? When I simply add a around it, I get the evil blank page. I'm no PHP whiz, but I know it has something to do with the quotes in the href conflicting with the (" "); quotes.

    Thoughts?

    Thx
    CT

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  2. Please post the complete code you are using at pastebin.com or pastie.org and we will take a look. It is likely a syntax error caused by mismatched quotes.

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  3. CraigTommola
    Member

    http://pastebin.com/rMh01ULN

    I don't currently have the link applied to the "Buy them here." text, but you'll see where I mean.
    The URL of the form is at the top of the code.

    Thx
    CT

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  4. Please post the code which was not working so we can check it for syntax errors. Post the code you want to use.

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  5. CraigTommola
    Member

    http://pastebin.com/dzSXkCmE

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  6. Try this version:
    http://pastebin.com/Kwnh1QBQ

    The links in your string were using double quotes for the href. You can't do that unless they are escaped with a backslash. Or, you can use single quotes, which is what I did for all your links.

    Let me know if that works for you.

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  7. CraigTommola
    Member

    I actually believe I tried single quotes, and backslash double quotes, but I'll give it a go and let you know.

    Thx
    CT

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  8. CraigTommola
    Member

    Single quotes don't result in a white page, but the confirmation message doesn't include the link. It appears as if the GF confirmation somehow stripped the link right out. It keeps the line breaks just fine, but the link is just *gone*

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  9. At least you have gotten rid of the syntax error and white screen: that is progress.

    Do you have a link to the page on your site where we can test this?

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  10. CraigTommola
    Member

    http://www.goracertech.com/blog/spring-selector/

    Posted 11 years ago on Monday January 7, 2013 | Permalink
  11. CraigTommola
    Member

    Any updates?

    Posted 11 years ago on Tuesday January 8, 2013 | Permalink
  12. Craig, I made some progress with this but did not resolve it. However, I can tell you at least how to allow the tags through. You need to use the gform_allowable_tags filter. I used it like this, which would apply to form 20, and will allow < p >, < br > and < a > tags through:

    [php]
    // change the 20 to your form ID
    add_filter("gform_allowable_tags_20", "allow_some_html");
    function allow_some_html($allowable_tags){
        return '<p><br><a>';
    }

    That allowed the link to come through in the confirmation message, however, on my site, the opening < and closing > were converted to entities, so the HTML ends up being displayed and it's not rendered as a link.

    Maybe this will help point you in the right direction. At least this much will be required to prevent the tags from being stripped. The next step will be to prevent them from being converted to entities.

    Posted 11 years ago on Wednesday January 9, 2013 | Permalink
  13. CraigTommola
    Member

    Did you add this is in the functions.php file? or perhaps forms_model.php?

    Thx
    CT

    Posted 11 years ago on Wednesday January 9, 2013 | Permalink
  14. Never modify any of the Gravity Forms plugin files. That code is added to your theme's functions.php file.

    http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F#PHP

    Posted 11 years ago on Wednesday January 9, 2013 | Permalink
  15. CraigTommola
    Member

    That code brought me the evil blank page again. I added it directly before:

    // set the recommendation link

    In the code I showed you.

    Thx
    CT

    Posted 11 years ago on Wednesday January 9, 2013 | Permalink
  16. CraigTommola
    Member

    I moved it up, just above the add_action for gform_pre_submission. No white page. However, it still stripped the tags.

    Posted 11 years ago on Wednesday January 9, 2013 | Permalink
  17. That was not my experience: the HTML was allowed through. You can see it in action if you submit this form: http://gravity.chrishajer.com/leadership-iq-test/

    The confirmation screen will show the HTML for a link in it. So, we're half way there with allowing the tags through. Please make sure you get this much working.

    Posted 11 years ago on Wednesday January 9, 2013 | Permalink
  18. CraigTommola
    Member

    Where did you paste the code you provided, in relation to the code I provided to you?

    Posted 11 years ago on Thursday January 10, 2013 | Permalink
  19. CraigTommola
    Member

    I have tried numerous instances of what you described. Nothing is working to let the link through or even provide a line break.

    Please post your functions.php content related to your successful execution in a pastebin, or respond to the above question about position of the snippet.

    Thx
    CT

    Posted 11 years ago on Friday January 11, 2013 | Permalink
  20. Craig, the position of the code in the functions.php does not matter, so long as it's not inside another function or code block, and is properly inside <?php tags. I actually have it in an external file, just to simplify management of the snippets for each form.

    Here is that code http://pastebin.com/NqhE2ujG

    This is the entry in my functions.php:

    [php]
    require_once(get_stylesheet_directory() . '/inc/20.php');

    The snippet is stored in my child theme folder, inc subfolder and then in 20.php:

    /htdocs/wp-content/themes/child/functions.php
    /htdocs/wp-content/themes/child/inc/20.php
    Posted 11 years ago on Friday January 11, 2013 | Permalink
  21. CraigTommola
    Member

    Still didn't work.

    Posted 11 years ago on Monday January 14, 2013 | Permalink
  22. Craig, the process I used worked for me so far as at least allowing the HTML tags into the post. Have you gotten to that point? That much will be required before we can go any further. We can't log in to your site and do the programming for you, but we do try and show you what needs to be done.

    Can you explain what is happening now?

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  23. CraigTommola
    Member

    I have made sure my syntax and use of quotes exactly matches yours.
    I have placed the allowable_tags filter exactly where you have it (other locations didn't allow tags, or caused a white screen)
    I see no change in output.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  24. CraigTommola
    Member

    If I wrap the output in htmlentities( ) then it shows the code, but doesn't render it as a link. Does that help at all??

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  25. CraigTommola
    Member

    I also tried replacing the < > with & l t ; and & g t ; and wrapped it with html_entity_decode( )
    This reverted it back to having no html display at all. So much for tricking it.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  26. Craig, it's hard to tell from here why it's not working for you. Since you are a developer license holder, I would open a priority support ticket and see if someone can offer advice or take a look.

    http://www.gravityhelp.com/priority-support/

    Posted 11 years ago on Tuesday January 22, 2013 | Permalink
  27. CraigTommola
    Member

    Done. Hopefully we can address this today.

    Posted 11 years ago on Tuesday January 22, 2013 | Permalink
  28. Any update Craig? I have not heard from Priority Support what the resolution was.

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink