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.
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.
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.
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?
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');
Ah that's it. Brilliant thank you. Everything's working now :-)