Support

Account

Home Forums Pre-purchase Questions Add repeater fields, but not edit/delete old ones? Reply To: Add repeater fields, but not edit/delete old ones?

  • I have done something similar in the past. On one client site I have an options page with several repeaters. The client can add new rows, and they can reorder the existing rows but they cannot delete or edit existing rows.

    Actually, it’s a little more complicated because the rows created are used to dynamically populate a select field that is used on a specific CPT. They are not allowed to delete a value after that value has been used on a post. So when the options page is loaded a check is done of each value to see if it has been used.

    This locking of rows is all done using JavaScript. A JS variable is added that contains a list of the values and if they are used or not and then when then page loads a script runs that locks all the rows that cannot be deleted.

    So, yes this can be done, but it requires JS. Using JS you can also remove the ability to change the order of rows as well.

    This is not a perfect solution because anyone that knows there way around well enough could get past it if they really wanted to.

    This could also be done by creating a field for inputting new data and then creating an acf/save_post action that takes the content in these fields and adds them to the repeater so that the repeater is not actually where the content is added thus removing the need to show the repeater to users in the first place and this would remove the ability to bypass the JS solution.