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 PHP to confirmation

  1. I would like to be able to add some PHP to the confirmation of a form.

    Anyone able to provide assistance on how to do this?

    So once a user has entered their name and email, they are present with a download which is on a post-by-post basis.

    Posted 13 years ago on Tuesday April 12, 2011 | Permalink
  2. The confirmation message doesn't support PHP, however it does support shortcodes. So the easiest thing to do would be to encapsulate what you want to do with PHP into a shortcode and place that shortcode into the confirmation message text.

    Posted 13 years ago on Tuesday April 12, 2011 | Permalink
  3. I've created a shortcode to output the code I want. It works in the post and if I enter it in the sidebar but it's not working in the gravity forms confirmation.

    This it the code:

    function formDownloadSC() {
    global $post;
    echo do_shortcode(get_post_meta($post->ID, "post-download", $single = true));
    }
    add_shortcode('formDownload', 'formDownloadSC');

    With the shortcode being [formDownload], and post-download being a custom field for another shortcode.

    Any ideas?

    Posted 13 years ago on Thursday April 14, 2011 | Permalink
  4. It looks like there is a small mistake in your code. Your should "return" the shortcode content and not "echo" it. Try using the code below:

    function formDownloadSC() {
        global $post;
        return do_shortcode(get_post_meta($post->ID, "post-download", $single = true));
    }
    add_shortcode('formDownload', 'formDownloadSC');
    Posted 13 years ago on Thursday April 14, 2011 | Permalink
  5. Ah that's it. Brilliant thank you. Everything's working now :-)

    Posted 13 years ago on Friday April 15, 2011 | Permalink

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