Support

Account

Home Forums Add-ons Repeater Field Repeater Field, saving wrong with update_field on first value

Unread

Repeater Field, saving wrong with update_field on first value

  • i am trying to save data from frontend , i have a repeater in profile user where i save many videos as repeater.

    when i insert from backend it works perfect , but when i do it in frontend with the update_field function , when theres no video previous , the data is stored wrong see the attach image. this is my code

    $user_id = $current_user->ID;

    if(have_rows(‘videos’, ‘user_’.$current_user->ID))
    $videos = get_field(‘videos’, ‘user_’.$current_user->ID);
    else
    $videos = array();

    //insert video to array
    if($video_url != “”)
    {
    $videos[] = array( ‘url_video’ => $video_url , ‘title_video’ => ”, ‘file_path’ => ” );
    update_field(“videos”, $videos, ‘user_’.$current_user->ID);
    }

    when i use this and the data is empty it saves bad in the database, but if exists 1 video and save in frontend the data is stored good , see the attach and you understand

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.