Support

Account

Home Forums ACF PRO Options page in front-end Reply To: Options page in front-end

  • Right now I’ve got the following working:

    1. Read all field groups using acf_local()->get_field_groups().
    2. Filter out all that are not in options pages as per the location matching rules.
    3. Get fields for all groups that are matched using acf_get_local_fields( $fieldgroup_key ).
    4. Read group keys and field keys.
    5. Output HTML based on group and fields as in foreach ( $groups as $fields ) : foreach ( $fields as $field_key => $field_data ) : printf( ... ); endforeach; endforeach;
    6. Said outputted fields are sent using standard HTML form element to the same page template (action="").
    7. Validation, referers, nonces, etc.
    8. Use the POST data to read field keys and update the database values from sanitized $_POST using update_field( $field_key, $value, 'options' ).

    Currently this works fine for non-JS infused fields, such as selects, text fields and so on. I’m working on getting the color picker working, which in the end should use a hidden text field anyway.

    Is there a more correct way to do this or should I wrap this into a plugin of sorts?