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


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.

    • Elliot

    • January 14, 2014 at 9:20 am

    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.


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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.