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

  • Show error

    Warning: Invalid argument supplied for foreach() in /home/users/test.com/wp-content/themes/mytheme/functions.php on line 630

    line 630:

    foreach($posted_flexible as $layout){

    I found this question – https://wedevs.com/support/topic/readingediting-acf-fields-with-wp-user-frontend/

    But it is unclear how this method of addition of ACF in the WP User Frontend, so I started using http://docs.wedevs.com/docs/wp-user-frontend-pro/developer-docs/action-hook-field/

    UPD:

    I replace flexible type on text type field, does not work.

    function flexible_field_form( $form_id, $post_id, $form_settings) {
    
        $new_post = array(
            // PUT IN YOUR OWN FIELD GROUP ID(s)
            'field_groups'       => array(116), // Create post field group ID(s)
            'form' => false
        );
        acf_form( $new_post );
    
        // insert the post
        $post_id = wp_insert_post( $post );
        $field_key = "field_56d32aaeb2284";
        $posted_flexible = $_POST["acf"][$field_key];
        
        $value =  get_field($field_key);
        update_field( $field_key, $value, $post_id );
    }
    
    add_action( 'flexible_field_hook', 'flexible_field_form', 10, 3 );

    Field does not load the data into a form, and does not add.