I've integrated custom fields using Advanced Custom Fields plugin on a submission form created using Easy Digital Downloads - Frontend Submissions add-on.
Custom fields display properly on the frontend but don't save/update the value when editing/updating the form. Default form fields work as expected - just custom fields don't work.
As per Easy Digital Downloads - Frontend Submissions add-on guidelines, I've added the following hook that integrates the custom fields within the form.
add_action('some-hook-name', 'my_modify_dd_form', 10, 3);
function my_modify_dd_form($form_id, $post_id, $form_settings) {
$args = array(
'post_id' => $post_id,
'field_groups' => array(16),
'form' => false,
'return' => ''
);
acf_form( $args );
}
Using the above hook, I am able to populate ACF fields on the frontend – submission form but the values/changes are not saving/updating even though added acf_form_head();
in the template header.
More on Frontend Submissions - Form Builder Acton Hooks can be read at https://docs.easydigitaldownloads.com/article/962-frontend-submissions-form-builder
Am I missing anything?
Finally, I've managed to fix this myself.
As I've set the form option to false, I had to manually process the ACF fields (by checking the post variables) and update the field values using the ACF function update_field
.
Eg.
if ( !empty( $_POST['acf']['field_5ecb0c4663b4r'] ) ) {
$mood = $_POST['acf']['field_5ecb0c4663b4r'];
update_field( 'field_5ecb0c4663bf7', $mood, $post_id );
}
wp_ajax_fes_submit_submission_form
and wp_ajax_nopriv_fes_submit_submission_form
are the hooks that handles Easy Digital Downloads - Frontend Submissions add-on's form submission process.
I hope this will help someone looking for a similar solution.