Home Forums ACF PRO How to use acf_form input names


How to use acf_form input names

  • Hi all,

    I’m using an acf_form with color inputs to give the front-end user some customisation options to the front-end.
    After setting these colors, I save that to a specific CSS file.
    I do that after submitting the acf_form.
    The acf_form uses hidden input fields where the actual data is stored. The name of such an input field could be acf[field_58d90ee4eabc2].
    In PHP I want to retreive the value of that input field, so this is what I do:
    $new_color_header_bg = $_POST['acf[field_58d90ee4eabc2]'];
    But this way the variable $new_color_header_bg stays empty.

    Am I missing something here?
    Maybe PHP gets confused by the [ and ] in the name, but how to resolve this.

  • You need to use $new_color_header_bg = $_POST['acf']['field_58d90ee4eabc2'];

  • John,

    That’s it! Thank you.
    After I posted this question I realised that all Post data is available in an array, so I was already thinking about some array ‘sniffing’ to get to the correct values.
    But to be honest, I never thought of this one.

    You have been very helpfull, as always.

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

The topic ‘How to use acf_form input names’ is closed to new replies.