Hi,
The overview:
There is a page with a form which the user needs to fill in. After hitting submit, the form redirects to a “Thank You” page. This thank you page displays a link to a PDF that can be downloaded. I’m using ACF and need some help with passing values across pages.
This is how I have it setup.
In the backend, I have an ACF field “goody_file” which contains the document and is not displayed on the form page. So when the user fills int he form and hits submit, I pass the page id along to the thank you page. Using the page ID, I’m trying to get the “goody_file” to display.
But it hasn’t worked. Here is my snippet:
Form Page: (package up the post ID in a hidden field and submit the form)
<?php
echo '<input type="text" name="activepost" id="activepost" value="'.get_the_ID().'" />';
?>
Thank You Page.
<?php
$pageid = $_POST['activepost'];
?>
<?php
$goody_file = get_field('goody_file', $pageid);
// Test echo of page id. It displays the right ID.
echo "$pageid";
if($goody_title) {
echo '<h2>';
// Spits out the full URL for now as a test.
the_field('goody_file');
echo '</h2>';
} else {
echo 'Did you forget to upload a file?
';
}
?>
I know I am so close. Any help would be greatly appreciated.
1. Variable $goody_title
is defined nowhere, probably you mean $goody_file
echo "$pageid";
if($goody_title) {
2. $pageid
missing at the_field()
, try this
// Spits out the full URL for now as a test.
the_field('goody_file', $pageid);
instead of this
// Spits out the full URL for now as a test.
the_field('goody_file');
Awesome. My eyes were blurry. That did the trick. Thanks!
Hi i Just tried this codes but it seems the pageID is not being capture from the previous or Form page any idea?