Support

Account

Home Forums Front-end Issues Easy Digital Downloads – Frontend Submission customisation ACF Fields

Solving

Easy Digital Downloads – Frontend Submission customisation ACF Fields

  • Is there a way to integrate ACF fields into an Easy Digital Downloads plugin extension? (Front End Submissions).

    I’m looking to add custom fields not already present in the submission form editor on Easy Digital Downloads’ Front End Submission add-on.

    One of the ‘blocks’ in the user-submission form editor allows me to add an ‘Action Hook’ which seemingly allows me to hook any function I want into the form. The help for that block is as follows…

    This is for developers to add dynamic elements as they want. It provides the chance to add whatever input type you want to add in this form.

    You can bind your own functions to render the form to this action hook. You’ll be given 3 parameters to play with: $form_id, $post_id, $form_settings.

    add_action(‘{hookname}’, ‘my_function_name}’, 10, 3 );
    // first param: Form Object
    // second param: Save ID of post/user/custom
    // third param: Field Object
    function my_function_name( $form, $save_id, $field ) {
    // Do whatever you want here
    }

    Using that, would it possible for me to add ACF fields/elements, or indeed an entire fieldset, into the EDD frontend submission form?

    Thanks.

  • Yes, you would use that hook and then call acf_form() https://www.advancedcustomfields.com/resources/acf_form/

  • How would I go about doing this? I’m slightly confused about how to implement this.

  • You need to create an action using the hook provided by the other plugin, you did not provide this hook name. Also, the details of how to use this hook are not clear. I also do not know what will be is save ID. Is it just the ID? Is there anything to tell you the object type that is being saved? You will need this information to call acf_form() for anything other than a post. Most of the following is a guess based on the information you’ve provided, more than likely it is not 100% correct.

    
    add_action('some-hook-name', 'my_modify_dd_form');
    function my_modify_dd_form($form_id, $post_id, $form_settings) {
      $args = array(
        // assuming that this is going to be saved to a post
        'post_id' => $post_id,
        // other acf form settings as needed
        // see https://www.advancedcustomfields.com/resources/acf_form/
      );
      acf_form($args);
    }
    
  • I run into the similar issue. @olijames Did you ever find a solution to this?

    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 front-end – submission form but the values/changes are not saving/updating even though added acf_form_head(); in the template header.

  • 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.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.