Home Forums General Issues Passing a value from ACF form to next page


Passing a value from ACF form to next page

  • This is probably pretty simple, but I haven’t been able to figure out how to do it.

    I have set up a front-end form that allows users to create new posts.

    Like this:

    $args = array(
      'field_groups' => array(123),
      'post_id'      => 'new_post',
      'return'       => home_url('thanks)

    Upon filling out the form the new post is created and the user is redirected to the ‘thanks’ page that shows the user some similar posts that others have posted.

    What I want to do is (1) pass the post ID of the post just created so the user doesn’t see their own post in the suggestion, and (2) pass the result of my ACF-category field (dropdown) and filter the results of my query so the user only sees posts of the same category they posted.

    So basically, my question is how I can pass the post ID and the chosen value from my ACF category field to the next page?

    Thanks a lot!

  • You could try appending this information to the URL of your “thanks” page:

    $post_id = (int) wp_insert_post( array(...) );
    $cat_id = (int) get_field('cat_field');
    $return_url = site_url( "/thanks/?post_id=$post_id&cat_id=$cat_id" );
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.