Home Forums Add-ons Repeater Field front end repeater manager


front end repeater manager

  • Hi!

    I need a repeater administration panel on the frontend.
    I have user-based posts, and i created “actions” with repeater. My registered users can edit our “actions” on the frontend. My problem: how can i update the specific repeater row on the specific post?

    I have a custom page (no wp loop) where I listing the necessary actions with get_field in a custom form.

    $field_key = "field_xxxxxxxxxx";
    $actions = get_field($field_key, $postID);
    $count = 0;
    foreach ($actions as $action) {
      $count+=1; ?>
      <form method="POST" ..... >
        <input type="text" ... value="<?php print $action['name']; ?>" />
        <input type="text" ... value="<?php print $action['date']; ?>" />
        <input type="hidden" .... value="<?php print $postID; ?>" />
        <input type="hidden" .... value="<?php print $count; ?>" />
        <input type="submit" .... value="Modify this action" />
     </form> <?php

    (this is only sketch 🙂 )

    In this case i haven’t sub field keys, only the name, the value, and the row count variable.

    After the form submit, I read the $_POST data which contains:
    – sub field names
    – sub field new values
    – counted row number
    – and i have a post ID and the repeater field key.

    Here is my problem: how can i update (change current value) the necessary sub fields the specific repeater in this post?

    I tried update_field() but how can i specific the sub field?


  • You need the post ID, the repeater field name, the sub field name and the index of the row of the repeater that you want to update.

    The easiest way to update the value would then to update the metadata directly using

    $meta_key = $repeater.'_'.$index.'_'.$sub_field;
    update_post_meta($post_id, $meta_key, $new_value);
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘front end repeater manager’ is closed to new replies.