Home Forums Backend Issues (wp-admin) CF7 posted data to ACF field


CF7 posted data to ACF field

  • I’m building a form using ContactForm7 that I need to post the submitted data into ACF field in new post when the user click submit button.

    Here’s the preview of the array that I’ve got from the WPCF7_Submission::get_instance();

        [workshop-title] => DIY: Last-Minute Halloween Costume
        [choose-schedule] => Array
                [0] => DIY - Painting (3pm)
                [1] => DIY - Crafting (8pm)
        [workshop-name] => Test
        [workshop-phone] => +1234
        [workshop-email] => [email protected]
        [workshop-payment-channels] => Array
                [0] => BCA
        [workshop-attach-payment-proof] => 1ffbfc8124cbd02b2933818458ff6acb

    My question is, how can I manage the output of WPCF7_Submission::get_instance(); data to ACF selected field with newly created custom post? What function I can use and how to use it? 😀

    Thank you.

  • *Update*

    I successfully create a new post with wp_insert_post function.

    The problem now, I can’t store the CF7 data in a specific ACF field. What should I do?

    Here’s my current function:

    function save_my_form_data_to_my_cpt($contact_form){
        $submission = WPCF7_Submission::get_instance();
        if (!$submission){
        $posted_data = $submission->get_posted_data();
        $new_post = array();
        $new_post['post_title'] = $posted_data['workshop-title'];
        $new_post['post_type'] = 'my_custom_post_type';
        $new_post['post_content'] = $posted_data['workshop-name'];
        $new_post['post_status'] = 'publish';
        //When everything is prepared, insert the post into your WordPress Database
        $post_id = wp_insert_post($new_post))
  • *UPDATE*

    This documentation really solves my problem, thank you:

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

You must be logged in to reply to this topic.