Support

Account

Home Forums ACF PRO Add a field from the ACF Pro in the form WP User Frontend Pro Reply To: Add a field from the ACF Pro in the form WP User Frontend Pro

  • Hi @ingwine

    I’m not sure how WP User Frontend Pro works, but I believe you can do it like this:

    function flexible_field_form( $form_id, $post_id, $form_settings) {
    
        $new_post = array(
            // PUT IN YOUR OWN FIELD GROUP ID(s)
            'field_groups'       => array(52), // Create post field group ID(s)
            'form' => false
        );
        acf_form( $new_post );
    
        // insert the post
        $post_id = wp_insert_post( $post );
        $field_key = "field_1234567890";
        $posted_flexible = $_POST["acf"][$field_key];
        
        $value =  (get_field($field_key) ? get_field($field_key) : array());
        foreach($posted_flexible as $layout){
            $value[] = array("sub_field_1" => $layout['field_1111111111'], "sub_field_2" => $layout['field_2222222222'], "acf_fc_layout" => $layout["acf_fc_layout"]);
        }
        update_field( $field_key, $value, $post_id );
    }
    
    add_action( 'flexible_field_hook', 'flexible_field_form', 10, 3 );

    When you post some Data from ACF form, you can get them using $_POST["acf"].

    I hope this makes sense.