Support

Account

Home Forums Add-ons Repeater Field Issue with updating repeater sub-field (image field)

Unread

Issue with updating repeater sub-field (image field)

  • Hi gues!

    I need some help with updating repeater field (actually image sub-field) from front-end.

    Use ACF v. 5.9.2.

    My code

    
    $user_id = get_current_user_id();
    
    $orders = get_field('order_and_screenshot', 'user_' . $user_id);
    
    foreach ($orders as $order) {
    
        $order_screenshot = $order['order_screenshot'];
    
        if (  !$order_screenshot ) {
    
             acf_form(array(
                'post_id' => 'user_' . $user_id,
                'fields' => array(
                    'order_screenshot' //sub-field name
    	    ),
            ));
    
        }
    }
    

    I select an image and submit the form. After submitting the post image is not updated on the back-end (user page). But I see this image on the front-end.
    Checking the database. And find these fields in wp_usermeta:

    order_and_screenshot_0_order_screenshot
    order_and_screenshot_1_order_screenshot
    order_and_screenshot_2_order_screenshot
    order_screenshot //I can’t understand why. The value of this field contains the correct image id, which is what I need. But I don’t created it (in repeater field only, not separate).

    How can I properly update this image field in a loop?

    I would appreciate your help! Thanks you!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.