Home Forums ACF PRO Can\'t get the name value to use $_POST Reply To: Can\'t get the name value to use $_POST

  • As I explained previously, $_POST is not available when the page is being displayed, it simply has no value.

    1) The page loads and displays the form
    2) You fill out the form and submit it
    3) acf_form_head() detects that the form was submitted. Your template for this has not been loaded, and even if it was the code in it would not run because ACF is taking control at this point.
    4) acf does acf/save_post action You can hook into the both before and after ACF saves the data in fields
    5) When processing is done ACF redirects, this can either be to the post page or somewhere else if you use this setting in acf_form(). Because of the redirect $_POST has no value when your template for the page is run because no values are submitted in the redirect.

    If you want to do something with the data then you must do so during the acf/save_post action.

    Optionally, you could also do this during the acf/pre_save_post action that is also called for a form inserted using acf_form(), but this would generally only be done if you want to customize $post_id in some way before ACF calls acf/save_post.