Home Forums Add-ons Repeater Field Loop thru Users and Repeated Field


Loop thru Users and Repeated Field

  • I need to generate a table that loops through users and displays 2 columns: 1) the user display name; and 2) a frontend-editable text area labeled ‘status”. The purpose is to allow user to edit not only their own status, but also any other user’s status.

    I assume that I need to use acf_form(), and maybe(?) a repeater field. What’s the most straightforward way to accomplish this? Do I need to create individual user status posts and use a repeated field for the form?

    I already have a custom user status field. But I’m a bit confused about how to set up a repeater field and combining it with acf_form() for displaying the editable status form.

  • You cannot use acf_form() for this. The reason is that you want to have a single form that updates a field but multiple user. Well, you may be able to use acf_form(), but either way you need a custom form for this page.

    There are many steps. Basically to use acf_form() you would need to create a field group that is used only on this page that has the repeater. You would need to create a filter for the repeater field, I’m not sure right now if it should be acf/load_value or acf/prepare field.

    The you would need to create an acf/pre_save_post filter that reads through the submitted repeater field and updates each user accordingly and then somehow prevents ACF from updating the values. Alternatively to the pre_save_post filter you could set up the acf form to save the values to an options page and then use an acf/save_post filter to read through the repeater and update the user fields.

Viewing 2 posts - 1 through 2 (of 2 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.