Support

Account

Home Forums Front-end Issues Pass acf_form $_POSTed variables to Page

Helping

Pass acf_form $_POSTed variables to Page

  • I’m attempting to build a simple (ish) filter form with ACF. What I had assumed/hoped would happen is that I could grab the $_POSTed variables on the reloaded page and use them to adjust my query variables. However, I see now that those form contents aren’t available on the reloaded page.

    I’ve got as far as hooking into acf/save_post where I can see the $_POST but am looking for a way to forward those values back onto the reloaded page.

    I don’t need to save the form values anywhere and have passed post_id => false to my acf_form settings.

    Here’s my save_post function. Can anyone suggest a way to access these on my reloaded page after the form is submitted?

    public function acf_save_deals_filter( $post_id ) {
    
    	if( isset( $_POST['acf'] ) && array_key_exists( 'field_63177d0340b69', $_POST['acf'] ) ):
    
    		printr( $_POST );
    		exit;
    
    	endif;
    }
  • Using an ACF form in this case would not be the best way to accomplish what you want to do. ACF forms save data and then redirect back to the submitting page, or another page based on the form settings. There really isn’t any way to prevent this.

    You want to create searching and filtering on an acf field. For this see the section titled

    Dynamic $_GET parameters

    on this page

    https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.