Support

Account

Home Forums Front-end Issues Update repeater with front-end image(s) upload

Solved

Update repeater with front-end image(s) upload

  • Hello,

    I’m trying to update a repeater field with an upload form (image/s) from the front end (WP 3.8).

    No problem when i save the image to a simple field, but not with a repeater :
    I validate the form, but can’t open it from the back end (always loading, and finally an error in the post (Fatal error: Maximum execution time of 30 seconds exceeded in plugin.php).

    Repeater field is named “images”.
    Rows are named “image”.

    Here is part of my code :

    
    // I get the attach_id
    $attach_id = media_handle_upload( $file_handler, $addPost );
    
    // And try to update the repeater field
    $field_key = "field_52d2cfbc5778a";
    $post_id = $addPost;
    $value = get_field($field_key, $post_id);
    $value[] = array('image' => $attach_id);
    update_field( $field_key, $value, $post_id );
    

    Something wrong with my code ?

    Thank you.

  • Resolved.

    Had to use add_action(‘init’) in functions.php to get it work.

  • Hi @mvdesign

    Yes. Because the add-on is not loaded until the init action has been fired, the update_field won’t work with the repeater field until then.

    Thanks
    E

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

The topic ‘Update repeater with front-end image(s) upload’ is closed to new replies.